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

Multiple form submits, how to detect which one?

Status
Not open for further replies.

fdarkness

Programmer
Joined
Feb 17, 2006
Messages
110
Location
CA
I have a form with three ways to submit it: the standard submit button and two links. They all work properly, except for one problem... I need to pass a variable if one of the two links is clicked.

For example, my code looks something like this:

(form name=form action=process.asp)
(span onclick="document.form.submit();")Accounts(/span)
(span onclick="document.form.submit();")Requests(/span)
(input type=submit)

(very simplified of course)

Suffice to say, it all works... my form variables and hidden variables are passed to process.asp. But I need to set a variable or value when Accounts or Requests is clicked so I can do extra functions in the process.asp page that won't be executed if the submit button is pressed.

I've tried setting value and name for the (span) tag, but that doesn't work. I thought using an A HREF tag would work, but if I put a value in HREF, then the form doesn't submit. Help! This has been driving me nanners for two days! (and I forgot to come here for help two days ago!)
 
You can always add a hidden field to the form and set its value prior to submission acording with the pressed button.

Cheers,
Dian
 
1) create a hidden field.
2) change the value of the hidden field right before you submit the form by using the "links".
Code:
onclick="document.forms['form'].elements['myHiddenFieldName'].value='something';document.form.submit();"



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top