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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Submit buttons??

Status
Not open for further replies.

usp004

ISP
Jul 10, 2000
46
US
I have and asp page that reads records from a DB and then displays them in a table. Some fields will be INPUT boxes to allow for editing.

There will be several SUBMIT buttons on this page depending on how many records were returned from the DB. How can I validate the INPUT boxes that belong to the SUBMIT button that the user has clicked on?

Thanks.
 
I saw an article detailing something similar to this on asptoday. Only this person used checkboxes to indicate which fields you wanted changed and then one submit button would handle all the updates.

Now in the discussion area there were some problems with the code in the article as written but maybe if you read the discussion area you will be able to figure out a solution to the problem.

Here is the URL

Hope it will help :cool:
 
Try this concept:

This is the forms page:

<form action='action_page.asp' method='post'>
<input type='image' name='previouspage' src='buttons/previous_page.gif' alt='Previous Page' value='previous' border='0'>
<input type='image' name='nextpage' src='buttons/next_page.gif' alt='Next Page' value='next' border='0'>
</form>


This is from the action_page.asp (that gets posted to):

<%
if len(request.form(&quot;previouspage.x&quot;))>0 then
'go back to the previous page
else
if len(request.form(&quot;nextpage.x&quot;))>0 then
'go to the next page
end if
end if
%>


Later,
Ken Kasmar
Red Falcon Internetworking, Inc.
webmaster@redfalcon.net
 
I had the same porblem as you I have an example of what you need, you may have to make a couple of changes to suit your needs.

my form page looks like this:

------------------------

<HTML>
<BODY>
<FORM METHOD=&quot;POST&quot; NAME=&quot;login&quot; ACTION=&quot;webdb.asp&quot; onSubmit=&quot;return checkPass()&quot;>


<input name=&quot;Group1&quot; type=&quot;submit&quot; value=&quot;submitbutton1&quot; onclick=&quot;javascript:gotonectpage(this);&quot;>
<input name=&quot;Group1&quot; type=&quot;submit&quot; value=&quot;submitbutton2&quot; onclick=&quot;javascript:gotonectpage(this);&quot;>
<input name=&quot;Group1&quot; type=&quot;submit&quot; value=&quot;submitbutton3&quot; onclick=&quot;javascript:gotonectpage(this);&quot;>


</FORM>
</BODY>
</HTML>

-------------------------------------

Inside the input tag you will see the three buttons have the value=&quot;submitbutton?&quot;, this gives each submit button a unique id, the name=&quot;Group1&quot; effectively groups these button so you can only check these button values only if you wish, it will make sense later on.

In the asp page this gets posted to, my code looks like this.

------------------------------------------

strAction = Request.Form(&quot;Group1&quot;)

Select Case strAlt

Case &quot;submitbutton1&quot;
then do this

Case &quot;submitbutton2&quot;
then do this

Case &quot;submitbutton3&quot;
then do this

End select
----------------------------------------------------------

the above checks the submit button &quot;group&quot;, and then uniquely check which button has been pressed by using the value of that button.

Hope this helps you out. If you have further questions, tell me.




 
of course I forgot to say you don't have to use a select case block, and the everything can be dynamically generated on the fly, so all the button values can be generated automatically as needed.
 
Taval:

That does sound like it will work. One more question though:

Within the form will be records with info to be updated. The number of records will vary, but can be different than the # of submit buttons. Example:

Item1
Input Value 1
Input Value 2
Input Value 3
Submit Button1

Item2
Input Value 1
Submit Button2

Item3
Input Value1
Input Value2
Submit Button3

How would you handle grabing ONLY the values of the Input Values when a user clicks on a certain Submit Button?? (Example (from above).. if the user updates Submit Button3 then I would need to update ONLY the 2 Input values associated with THAT submit button.)

Thanks for your help!
 
let me get this straight in my head, since its been I long day and I can't really think straight.

ok, so you're saying if you had say two text boxes with values in them and a submit button, how would you by clicking on that submit button only update the values from those two the text boxes, is this right?


ok heres anothoer example:

my form would look like :

--------------------------------------------

<HTML>
<BODY>
<FORM METHOD=&quot;POST&quot; NAME=&quot;login&quot; ACTION=&quot;webdb.asp&quot; onSubmit=&quot;return checkPass()&quot;>

<INPUT TYPE=&quot;text&quot; NAME=&quot;updatevariable1&quot; size=5 maxlength=5 >
<INPUT TYPE=&quot;text&quot; NAME=&quot;updatevariable2&quot; size=5 maxlength=5 >
<INPUT TYPE=&quot;text&quot; NAME=&quot;updatevariable3&quot; size=5 maxlength=5 >

<INPUT name=&quot;updatesubmit&quot; TYPE=&quot;submit&quot; VALUE=&quot;Update Records&quot;
onclick=&quot;javascript:gotonectpage(this);&quot;>

..you can have lots more text boxes, submit button etc here..

</FORM>
</BODY>
</HTML>

--------------------------------------------

my asp code might look something like this:

---------------------------------------------------

strAction = Request.Form(&quot;updatesubmit&quot;)

Select Case strAlt

Case &quot;Update Records&quot;
var1 = request(&quot;updatevariable1&quot;)
var2 = request(&quot;updatevariable2&quot;)
var3 = request(&quot;updatevariable3&quot;)

..............

End select
---------------------------------------------------


The above will work fine, but there is another way of doing it.

If I presume you will be generating the form on the fly, so for each group of &quot;items&quot; as you say you can generate a tag that you use for its input box VALUE, so for example item1 input box values might be tagged &quot;item1Var&quot;, and item2 input box values might be tagged &quot;item2Var&quot; then when you identify when button has been pressed on the asp page (see above) you can then take all the input boxes on the page associated with that button by doing

request(&quot;item&quot;&n&&quot;Var&quot;)

where n is an integer (useful if you are going to be looping the data). Anyway, tell me how you get on and if theres anything you're confused about tell me (coz I am, hehe).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top