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

buttons

Status
Not open for further replies.

travmak

Programmer
Apr 26, 2002
133
US
I'm rather new to form buttons. How can I make a button do something other than submit, and follow the forms action and reset, to clear the form?
I have a form that inputs data into a database. The forms action calls savedata.asp How do I make a "back to main menu" or "exit without saving"?

Thanks in advance
 
Code:
<input type=&quot;button&quot; value=&quot;back to main&quot; onClick=&quot;window.location='main.html'&quot;>
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
<input type=&quot;button&quot; value=&quot;Exit&quot; onclick=&quot;javascript:document.location='index.htm'&quot;> ....:::::.... xxLargeWASP ....:::::....
 
there are a number if way to make an exit without saving or back button. Firstly use input type=&quot;button&quot; like this instead of submit
Code:
<input type=&quot;button&quot; name=&quot;exit&quot; value=&quot;Exit Without Saving&quot;>

and then apply an onclick event to the button like this:

onclick=&quot;window.location.href='index.asp'; return false;&quot;

which will redirect the browser using Javascript. Alternatively you could call a Javascript function and do your actions from there.

hope this helps

rob
 
How do I make it call a VBScript function?

<input type = &quot;button&quot; name = &quot;button&quot; value = &quot;button1&quot; onClick=&quot;what goes here?&quot;>


<script language = &quot;vbscript&quot;>
function button1function()
instruction
instruction2
instruction3
instruction4
end function
</script>
 
Put your <script></script> stuff between the head tags, then have onClick=&quot;button1function&quot;

But use Javascript unless
a) You really can't (although there are loads of source code libraries available)

b) You know for sure that the users will only be using IE (or you don't care)
 
I.E. users. (Gov job) thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top