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

Qustion on basics

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi,

On my page I have got a couple of text boxes with submit button beside.

They are not inside of <FORM></FORM> tags.

What I want to do is OnSubmit event of each submit button runs a java script that depending on the values, submits the values to one or another .asp page.

Would I be able to do that? Or shold I have created a form?

Please advise.

Thanks
 
You could do that yes, but..
If you have no form you don't really have to use the onSubmit event. onClick will do. And your input type should better be &quot;button&quot; instead of &quot;submit&quot;.
You could add a javascript function to the different onClick events. Mind that you would have to pass things through the url string in that case.

The use of a form would make things a bit easier. You can change a form's action with javascript. Depending on the button clicked or the inserted values you could change the action of the form before submitting it.
eg:
if (value1 == &quot;test&quot;) {
document.form1.action = &quot;page1.asp&quot;
document.form1.submit();
}

Anyway, if you have multiple buttons don't start messing with submit buttons and onSubmit events... that will only give you a headache.

hope this helps
greetings


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top