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 Mike Lewis 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 and Validation

Status
Not open for further replies.

pparadis

MIS
Dec 5, 2000
22
0
0
US
I have a form that acts both as a search form and an inserting form. It has two submit buttons on it, one for searching and one for inserting new records. I need to validate the form before it is sent to the server. I'm using Javascript but can't find a way to determine which button has been selected so I can run the correct validation for it. Searching requires one type of validation and inserting requires another.
Thanks.
 
function submitMe(action){
document.theForm.action.value = action;
document.theForm.submit();
}

<form name=theForm method=post action=somePage.asp>
<input type=hidden name=action>
<input type=button value=Search onClick=&quot;submitMe('search');&quot;>
<input type=button value=Insert onClick=&quot;submitMe('insert');&quot;>
</form>

So that depending on what button you push, the hidden form variable gets set to one value or the other, and then the form is submitted. You then just need to evaluate the value of that element to decide what to do.

:)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top