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

sending a variable with Submit? 1

Status
Not open for further replies.

GaryCam

Programmer
Dec 16, 2003
69
US
I have a form which has two buttons which serve to submit the form:

<FORM name=&quot;frmModify&quot; action=&quot;register.asp&quot; method=&quot;post&quot; id=&quot;frmModify&quot;>
<INPUT type=&quot;image&quot; name=&quot;imageField&quot; src=&quot;one.gif&quot; onClick=&quot;submit();&quot;>
<INPUT type=&quot;image&quot; name=&quot;update&quot; src=&quot;two.gif&quot; onClick=&quot;submit();&quot;>
</FORM>

At the end of register.asp, I have a Response.Redirect back to this form. My question is this: What's the best way to get register.asp to return to the button that called it instead of just going to the top of the form? Seems to me each button will have a variable which is sent with the submit to be read by register.asp. I just don't know how to do it.

Thanks for your help.
~ Gary
 
GaryCam, try putting an anchor tag next to the <img>'s and then on register.asp link back to the appropriate anchor tag.

Just a suggestion...


____________________________________
Just Imagine.
 
>> Seems to me each button will have a variable which is sent with the submit to be read by register.asp.

Gary,

As far as I am aware, submit buttons and/or images don't give any identifying details to the form about themselves... Which means you'd still need to know which of the buttons you clicked.

You could do this by having a hidden input field, and onClick of either of the buttons, setting the value of that field before doing the submission. You'd also have to add A tags, as GUJUm0deL suggests (or use scrollIntoView, but a tags are easier):

Code:
<FORM name=&quot;frmModify&quot; action=&quot;register.asp&quot; method=&quot;post&quot; id=&quot;frmModify&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;whichSubmitButton&quot; value=&quot;&quot;>
<A NAME=&quot;button1Position&quot;></A>
<INPUT type=&quot;image&quot; name=&quot;imageField&quot; src=&quot;one.gif&quot; onClick=&quot;document.forms['frmModify'].whichSubmitButton.value='1'; submit();&quot;>
<A NAME=&quot;button2Position&quot;></A>
<INPUT type=&quot;image&quot; name=&quot;update&quot; src=&quot;two.gif&quot; onClick=&quot;document.forms['frmModify'].whichSubmitButton.value='2'; submit();&quot;>
</FORM>

Then you can link back to the submitting button by appending &quot;#buttonXPosition&quot; to your URL, where X is the value contained in the whichSubmitButton hidden field.

Hope this helps!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top