Hi Jayman,
    1.
        <form name="form1" method="post" action="details.jsp">
        <input type = "hidden" name="empname" value="">
        <ol>
        <%
            while(rs.next())
            {
        %>
                <li>
                <a href="javascript:onclick="submitForm('<%= rs.getString(1)
%> ')" ><%= rs.getString(1) %> </a>
        <%
            }
        %>
        </ol>
        </form>

        <script language="JavaScript">
        function submitForm(str)
        {
                document.form1.empname.value=str;
                document.form1.submit();
        }
        </script>

    or
    2. a simpler method
            <%
            while(rs.next())
            {
            %>
                <li>
                <a href="details.jsp?n=<%= rs.getString(1) %>"><%=
rs.getString(1) %> </a>
            <%
            }
            %>


    Have a nice day

xgh

----- Original Message -----
From: Jayman Dalal
To: [EMAIL PROTECTED]
Sent: Tuesday, June 20, 2000 01:26 PM
Subject: Submitting a form with hidden field


Hi...
I think u will be able to help me out.
I have a emp.jsp page which lists all employees as present in the
database as html links. When I click on any of the employee, I have to
list all the details of the employees, which i do so using the
details.jsp page, once again the details are in the database. Now I have
taken one hidden field "empname" just before listing the employees, and
using the onClick u specified below, I have to pass the name of employee
clicked to the details.jsp page.

<form name="form1" method="post" action="details.jsp">
<input type = "hidden" name="empname" value="">
<ol>
<%
        while(rs.next())
        {
                %>
                <li>
                <a href="javascript:onclick="submitForm()"
onClick="submitForm()">
                        <%= rs.getString(1) %> </a>
                <%
        }
%>
</ol>
</form>

<script language="JavaScript">
        function submitForm()
        {
                document.form1.empname.value=<%= rs.getString(1) %>;
                document.form1.submit();
        }
</script>

But still when I click on the listed employees, I remain on the same
page.
Please HELP!!!

Thanks
Jayman


Richard Cammarano wrote:
>
> I had the same problem and it drove me nuts. I'm glad I could save
> someone else the time....
>
> Cross-browser solution:
> 1) It seems that Netscape requires a form to have at least one element
> in order for a javascript submit to work. Make sure the form you are
> submitting has at least one input element (doesn't matter what it is -
> you can use hidden). Otherwise, the href post will not work in netscape.
>
> 2) The href should be rewritten as:
> <a href="javascript:onClick="p()" onClick="p()"> P </a>
>
> This should work!
>
> -----Original Message-----
> From: pawan.aggarwal
> Sent: Monday, June 19, 2000 4:17 PM
> To: JSP-INTEREST
> Subject: Submitting a form
>
> Hi All,
>
> Can we submit a form thru a hyperlink..
>
> <HTML>
> <BODY>
> <form name="thisform" method=post
> action="http://localhost:8080/servlet/Add">
>
> <A href=# onclick="p();">Hi there</A>
> </form>
> <script language="JavaScript">
> function p()
> {
> alert("hi");
> document.thisform.submit();
>
> }
> </script>
> </BODY>
> </HTML>
>
> When i run this only "Hi" is alerted with nothing happening??
> IS there some way out?
>
> ========================================================================
> ===
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> This message contains confidential information and is intended only
> for the individual named.  If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail.  Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete, or contain viruses.  The sender therefore
> does not accept liability for any errors or omissions in the contents
> of this message which arise as a result of e-mail transmission.  If
> verification is required please request a hard-copy version.  This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to