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!

launch script code when OnClick

Status
Not open for further replies.

alfredoalvarado

Programmer
Sep 3, 2002
2
VE
how can i to launch a sub or function (asp) when the user click on a button

in asp environment

 
You have to submit the page back to the server in order to call a server-side ASP function or sub.


So, for instance, you could do something like this:

<%
dim strAction

strAction = Request.form(&quot;hdnAction&quot;)

if UCase(strAction)=&quot;ADD&quot; then
call AddNew()
end if


sub AddNew()
...
end sub
%>
<script language=&quot;javascript&quot;>
function setAction(){
document.frmTest.hdnAction.value=&quot;Add&quot;;
document.frmTest.submit();
}
</script>

<body>
<form name=&quot;frmTest&quot;>
<input type=&quot;hidden&quot; name=&quot;hdnAction&quot; value=&quot;&quot;>
<input type=&quot;button&quot; name=&quot;btnAdd&quot; onClick=&quot;javascript:setAction();&quot;>
</form>
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top