Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting data from a form

Status
Not open for further replies.

AnthonyGeorge

Technical User
Jun 3, 2004
46
GB
I have a difficult problem with no idea how to solve it. I think javascript is the best approach, but have very limited experience of javascript

The problem is as follows at the moment I have the following code

while(rs.next())
{
%> <form name="setlimits" method=POST action="controlservlet">
<tr>
<td>
<input type="text" name="new_limit" size=10 value="0" >
<input type="hidden" name="index" value="<%= rs.getString("index") %>">
<td>
<tr>
<tr>
<input type="submit" value="Amend Limit">
</form>
<tr>
<%
}

When I press submit the control servlet is called and two parameters passed to it new_limit and a corresponding index.
This allows me to update a table row with the new_limit in the database where index = index.

What I have now been asked to do is supply a submit all button, when this button is pressed I should pass to the control servlet all the new limits with all the corresponding indexs.

As I see it I will prob have to write a javascript function that will pick up all the new limts and indexs and store them in a javascript document

Thanks for any help Tony

<
 
<form name="setlimits" method=POST action="controlservlet">

is inside the while loop, move it outside the while loop.

<input type="submit" value="Amend Limit">
</form>
move the above 2 also outside the while loop. u will have one submit all button...

Known is handfull, Unknown is worldfull
 
Hi Vbkris

My fault I did not explain the problem properly

I have the this form within a loop

<form name="limits" method=POST action="global">
<input type="text" name="new_limit" size=10>
<input type="hidden" name="borg_num" value="<%= rs.getString("borg_num") %>">
<input type="submit" value="Amend Limit">

when run it will look like this if I have 4 limits to set

limits
[] (amend limit)
[] (amend limit)
[] (amend limit)
[] (amend limit)

I enter data into one of the boxes say 10 and press the button (ammend limit) then the data entered 10 plus
the hidden identifier for that limit borg_num will be fired of to the control servlet.

I have been asked to add another button (ammend all)

limits
[] (amend limit)
[] (amend limit)
[] (amend limit)
[] (amend limit)

(amend all)

what this button will do is if I enter data in all four boxes on pressing submit I will need to get all 4 limits with all four matching borg_num identifiers and pass to the controlservlet.


I have written the amend all button

<input type="button" value="Amend All" onclick="submitAll()" />
<form name="allForm" method=POST action="global">
<input type="hidden" name="cmd" value="temp_limits">
</form>

and have started the javascript function
<script>
function submitAll()
{
document.getElementById("allForm").submit();
}
</script>

I have no idea how to pick up new_limit and borg_num from the form and store them in a document.

Thanks for any help.

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top