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

calling ASP code from an onClick event.

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
Can I do something like this:

<form name=&quot;frm_agr&quot; method=&quot;POST&quot; action=&quot;someFile.asp&quot;>
<input type=&quot;submit&quot; value=&quot;I AGREE&quot; name=&quot;Agree&quot;
onClick=&quot;myASPProcedure()&quot;>
</form>


<%
Sub myASPProcedure()

Dim Variables

go to a database and update fields

End Sub
%>

What I'm trying to do is that if a user agrees to my disclaimer and clicks &quot;i agree&quot; then I can immediately capture that from his/her mouse click and record it in my database

Thanks! How much more water would there be in the ocean if it weren't for sponges?
 
Once the page is sent to the user, you are no longer using server side code...therefore, you cannot access it using the client side procedures such as &quot;onClick&quot;.

If you didn't want to go to another page, you could have the onClick event open a new &quot;small&quot; window which would execute your .asp code to insert the information into the database and close itself upon finishing this action.

Would that solve your problem? -Ovatvvon :-Q
 
yes - i thought it probably wouldn't work, but I wasn't sure why - thank you for the clarification on that.

you're second suggestion i guess sounds feasible, you're saying that i could use javascript to open smaller window that says something like &quot;thank you for acknowledging our agreement&quot; which also has the asp code on it that writes the info back to the database, right?

how would it know when to close itself?
How much more water would there be in the ocean if it weren't for sponges?
 
On lunch right now, so don't have anything to double check myself, but try somthing like this:


<%
Dim userPK ' user's Primary Key
' Set the userPK variable
%>
<script language='javascript()'>
<!--
function agreement(userPK){
window.open(&quot;enterInfo.asp?userPK=&quot;+userPK+&quot;&quot;,&quot;windowName&quot;,Width=&quot;10&quot;,Height=&quot;10&quot;)
}
// -->
</script>
<%
' Find out if the user clicked on I agree...
' If so, call the agreement function &quot;agreement(&quot; & userPK & &quot;)
%>

It'll open the window with the page enterInfo.asp. Attached will be the user's primary key in the database. With that, you can execute the ado code and enter the agreement info into the database, after you close the connection, then close the window. &quot;window.close()&quot;

Gotta go, hope this helps! -Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top