my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Forms and values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Forms and values" Watch "Forms and values" New topic
Author

Forms and values

Tom Caldwell
Ranch Hand

Joined: Oct 09, 2000
Posts: 39
This is probably very basic as I haven't done much JavaScript in a while. I have a servlet which displays results from a database query in a FORM so that by clicking a field submits a 2nd servlet.
like
<FORM ACTION=/servlet2...
then several rows of
<tr><td><input type=submit value=? onClick=SubmitForm()>
<INPUT type='hidden' name='vx' value='" + value1 + "'>")
this is repeated for each row
===
everything works, the 2nd servlet is submitted and receives a value but "value1" is always the value of 1st row?. If I click on the nth row I expected it to pass the value for that row not always the 1st. What am I doing wrong ?
Thanks
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Submitting the form from a different location will not change the values of the data that are submitted. There are probably ways around this, but let me understnd what you are trying to do. You want to submit only part of the data on a form based on what row was used to submit it? Is that right? If so, probably the easies way to do this would be to have multiple forms on the page and allow the user to select which one they want to submit.
[This message has been edited by Bodie Minster (edited January 31, 2001).]
Tom Caldwell
Ranch Hand

Joined: Oct 09, 2000
Posts: 39
Yes,
This displays rows something like
? 111
? 222
? 333
where if you click on the last row it passes 111 where I was hoping to pass 333
Tom Caldwell
Ranch Hand

Joined: Oct 09, 2000
Posts: 39
Bodie,
I was looking at some examples, can you tell me why this doesn't this work? I modified the form to pass a value like >
<FORM name='queryForm' ACTION= ...
<tr><td><input type=submit value=? onClick=SubmitForm(03807836)
<tr><td><input type=submit value=? onClick=SubmitForm(01234567)
function SubmitForm(passedString)
{
document.queryForm.valuex.value=passedString
document.queryForm.submit()
}
So if you click on the 2nd one shouldn't valuex = 01234567 ??
Thanks
[This message has been edited by Tom Caldwell (edited January 31, 2001).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Yeah, that should work. Have you tried popping up an alert box inside your function to output the value before submitting the form?
Kerry Shannon
Ranch Hand

Joined: May 08, 2001
Posts: 31
Hey, this worked for us, where we were trying to put save, submit, and cancel buttons on the page all in one form that contains the data entered by the client.
Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Forms and values
 
Similar Threads
getting null value, from a variable being sent from JavaScript in the page
form values in a new windows
jsp sending values
sending updated array of javaBeans from JSP back to Servlet!
Passing form varables in a servlet