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

Two Buttons in Form

Status
Not open for further replies.

joetadalan

Programmer
Oct 3, 2002
5
0
0
US
I am trying to use the following code and having problems with how to get it to work -

<FORM ACTION=&quot; METHOD=POST>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;code&quot; VALUE = &quot;AZ3502&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;name&quot; VALUE = &quot;Frame with Steering Hoop&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;price&quot; VALUE = &quot;119.50&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;shpcost&quot; VALUE = &quot;25.75&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;wt&quot; VALUE = &quot;1&quot;>
<b>Qty:</b>
<SELECT NAME=&quot;qty&quot;>
<option value=&quot;0&quot;>
<OPTION value=&quot;1&quot;>1
<OPTION value=&quot;2&quot;>2
<OPTION value=&quot;3&quot;>3
<OPTION value=&quot;4&quot;>4
<OPTION value=&quot;5&quot;>5
</SELECT>
<INPUT TYPE=&quot;image&quot; src=&quot;graphics/add.gif&quot; width=28 height=20 border=0>
<br>
-------------------------------------------------
??

</form>

I have tried the following code in place of the ?? -

<INPUT TYPE=&quot;image&quot; src=&quot;graphics/addwishlist.jpg&quot; border=0
OnClick=&quot;???&quot;>
Not sure what should go here or even if this possible.

Also tried the following in place of ?? -
<a href=&quot;newpage.cfm&quot;><img src=&quot;graphics/addwishlist.jpg border=0></a>

What I am trying to do is use the form above and not have to create a new form to use the form variables and depending on which button you pick is what page will appear next. I do not want to change the code that is above the line if at all possible.

Is this a viable solution or could someone point me to a reference for something similar to this.

Thanks

Joe Tadalan
 
I forgot when I try and use
<a href=&quot;newpage.cfm> ... the newpage.cfm does not know about the variable in the form - I tried putting the form inside of a CFOUTPUT Tag.

I also tried to pass the variables using
<a href=&quot;newpage.cfm?code=#Code# ...>
This does not work - when newpage.cfm is displayed - I either receive the error that Code is not defined or in the Address at the top of my browser I see this -
newpage.cfm?code=#Code
 
are you trying to use multiple submit images? click one and get one action, or click the other and get a different action?

unfortunately, the action is determined by the FORM ACTION, and this means a form can only be sent to one place

so what you have to do is write the action template to detect which image button was clicked

make sure you supply a NAME parameter to each of the INPUT images so that the action template can detect which one was clicked

rudy
 
R937 -

I thought thats what the solution would be but I am trying to leave this code unchanged because this code is everywhere on our site -

<FORM ACTION=&quot; METHOD=POST>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;code&quot; VALUE = &quot;AZ3502&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;name&quot; VALUE = &quot;Frame with Steering Hoop&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;price&quot; VALUE = &quot;119.50&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;shpcost&quot; VALUE = &quot;25.75&quot;>
<INPUT TYPE = &quot;hidden&quot; NAME = &quot;wt&quot; VALUE = &quot;1&quot;>
<b>Qty:</b>
<SELECT NAME=&quot;qty&quot;>
<option value=&quot;0&quot;>
<OPTION value=&quot;1&quot;>1
<OPTION value=&quot;2&quot;>2
<OPTION value=&quot;3&quot;>3
<OPTION value=&quot;4&quot;>4
<OPTION value=&quot;5&quot;>5
</SELECT>
<INPUT TYPE=&quot;image&quot; src=&quot;graphics/add.gif&quot; width=28 height=20 border=0>
<br>

Would it be possible to use the other solution I am trying with the -
<a href=&quot;newpage.cfm?code=#Code# ...><img src=&quot;...> </a>

I can get the above to work, the only problem is the newpage.cfm does not seem to know about the form variables - is this not possible or do I have to add some other code to get the form variables passed to the new page ?

Thanks for your help in advance
Joe
 
>> &quot;I am trying to leave this code unchanged
>> because this code is everywhere on our site&quot;

no problem (assuming there's a </FORM> tag somewhere)

however, you would still have to add a NAME parameter to the existing image button

otherwise, the action page won't be able to detect it

(note: i have not done a two-submit-button form myself)

as for the <a href> technique, i don't think you will ever get that to submit the form fields


rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top