| Author |
Parameter passing problem
|
Azz Romaysa
Ranch Hand
Joined: Dec 08, 2004
Posts: 66
|
|
Hi, My problem is that I want to pass a parameter from a.jsp to b.jsp. I want to store my variable in e hidden input, and when I submit a link, the a.jsp will send the parameter to b.jsp. a.jsp ============================================== <form action="gekozenKind.jsp" method="post" name="submitKind"> <a href="gekozenKind.jsp"> <%= v_naam.get(i) %></a> <br> <%= v_gebDatum.get(i) %> <br> <%= v_afkomst.get(i) %> <input type="hidden" name="weesID" value="<%= v_id.get(i) %>"> </form> b.jsp ============================================== <%= request.getParameter("weesID") %> I tried this code but the <%= request.getParameter("weesID") %> returns always a null. Could someone help me to fix this prob? Abu Romaysa,
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
You're not submitting the form. Either replace the link with a submit button. <input type="submit"..... or use the onclick event in the anchor tag to submit the form instead of excecuting the link.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Azz Romaysa
Ranch Hand
Joined: Dec 08, 2004
Posts: 66
|
|
I do not want to use a button, because then I'll get a page with more then 21 buttons. I tried it with the button and it works great, but don't know how to do that with a link cuse that's what I wanna do. Thanks Abu Romaysa
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26173
|
|
Azz, You can also pass the parameter in the link itself. Note that it will be a GET request rather than a POST request: If you realy need a post, you can intercept the user's click through javascript. Have the onClick handler call a user defined function which submits the form.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
If you're repeating this in a loop, you'll want to build the form's id attribute dynamically. The "return false" statement in the onclick event keeps it from actually behaving like a link (probably redundent in this case but it makes for clearer code.). I know this works in Mozilla/Firefox and MSIE 6 and up. You'll have to test on legacy (pre DOM) browsers if you plan on supporting them. I had to mispell onklick to get this top post in this forum. Change the 'k' to a 'c' to get it working. [ December 26, 2004: Message edited by: Ben Souther ]
|
 |
 |
|
|
subject: Parameter passing problem
|
|
|