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

Multiple forms with images insead of submit buttons 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I can use an image instead of submit button on a form...
I can use multiple forms on the same page with submit BUTTONS and find out which form was posted...
But what if I have multiple images that have to act as submit buttons on the same page?
How do I figure out which form is posted? Calling the images the same name and assigning them different
values does not work. Response.Form("imageName") does not pick up the value of the image.

I was thinking of making one form use "post" and the other one "get" - but what if I have more than 2 buttons/images?

Please help if someone has a code snippet for it.
 
hi lana_p

set the images with the onClick property

use javascript to submit the form that u want

here is the script to submit the form

[tt] document.formname.method = "post/get"
document.action.method = "where u want to past the form to"
document.formname.submit()[/tt]

at formname pls replase it with the form that u want to submit
it will work
mail me if u have a problem

regards ::)

Unicorn11
abhishek@tripmedia.com

ENJOY !!!!!!!!!!
 
Image buttons don't pass their value, they pass the coordinates where the mouse was clicked (in the form buttonname.x=3&buttonname.y=4 - I'm not sure the exact syntax & I think it only works server side. So checking if buttonname.x != "undefined" might work.

Alternatively, keep the input type=image and put a hidden field in each of the forms & check if its name is returned. This wouldn't work if you had two image buttons in one form and needed to know which had been clicked, so you'd have to do as in the previous response, and have an img, with an onClick trigger which sets a value in a hidden field depending on the button clicked and then submits the form. Then you could check for the value of the hidden field.
HTH!
Tamsin
 
Hi,

I'm trying this last idea, calling a Javascript function from an onClick event, and trying to set the value of a hidden variable in the Javascript. But its giving me this error message when I try and set it:

Error: document.MyForm.hiddenVarName is null or not an object

Here's my hidden field declaration:
<input type=&quot;hidden&quot; name=&quot;hiddenVarName value=&quot;<%=hiddenVarName%>&quot;>

and in JavaScript:
in the if statement for a given condition:

{
document.MyForm.hiddenVarName.value = &quot;value&quot;;
document.MyForm.Submit;
}

Thanks for any ideas,
Ray
 
Here is a sample code .Hope it will help.

<CFFORM ACTION=&quot;yuhuuuuu.cfm&quot; METHOD=&quot;POST&quot; name=&quot;davor&quot;>

.
.
.
.


<!-- this is just to create object name choice-->
<input type=&quot;hidden&quot; name=&quot;choice&quot; value=&quot;abrakadabra&quot;>

<img src=&quot;../com/unos.gif&quot; onClick=&quot;document.davor.choice.value='unos'; document.davor.submit();&quot; >

<img src=&quot;../com/snimi.gif&quot; onClick=&quot;document.davor.choice.value='snimi'; document.davor.submit();&quot; >

</cfform>

 
Thanks Davor for the idea....

I'm still getting the same error when I try the code above:

'document.davor.choice' is null or not an object

 
for anyone with a similar problem, putting the word JavaScript: before the code in onClick cleared this up for me in a similar example I had....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top