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

How to call a asp function from onchange event?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I need to call a ASP function in the same page by firing the event onchange. Could I do it? and how to do it? I need to fill another dropdown lost using a query.

<SELECT size=1 id=select1 name=&quot;Category&quot; onchange=fillProcedure()>

<% sub fillprocedure()
end sub
%>


Haijun
 
You can't do this because ASP is processed before its sent to the browser. You could do it this way...

<SELECT size=1 id=select1 name=&quot;Category&quot; onchange=>

'on change goto... thispage.asp?update=category


<% If Request.QueryString(&quot;update&quot;) = &quot;category&quot; then

call FillProcedure

End if

%>

<%

Sub FillProcedure
'Do whatever
End Sub

%>
 
After I read your message, I know that we can not call a server function from client. Because the server code was executed before sending to the client. But I do not fully understand how to call server function using your method.
Could you expain more?

Thanks

Haijun
 
Haijun
Your page would have to redirect back to itself, thereby reloading the page. The querystring that you set in the redirect (thispage.asp?update=category) would be read at the top of the page (If Request.QueryString(&quot;update&quot;) = &quot;category&quot; then ...). then your page would know what to do when it reloaded.
 
If you are unfamiliar with querystrings you can see basicly what they do by making an asp page and putting this code in it. This will show you what can be accomplished with querystrings...

name it test.asp


<a href=&quot;test.asp?clicked=link1&quot;>Link 1</a><Br>
<a href=&quot;test.asp?clicked=link2&quot;>Link 2</a><Br>
<a href=&quot;test.asp?clicked=link3&quot;>Link 3</a><Br>
<a href=&quot;test.asp?clicked=show+all+querystrings&test=hello&test2=hello+there+blabla&quot;>Display all querystrings in a link</a><Br>

<%
If Request.QueryString(&quot;clicked&quot;) = &quot;link1&quot; then
Response.Write &quot;you clicked link 1&quot;
End if

If Request.QueryString(&quot;clicked&quot;) = &quot;link2&quot; then
Response.Write &quot;you clicked link 2&quot;
End if

If Request.QueryString(&quot;clicked&quot;) = &quot;link3&quot; then
Response.Write &quot;you clicked link 3&quot;
End if

If Request.QueryString(&quot;clicked&quot;) = &quot;show all querystrings&quot; then
Response.Write(Request.QueryString) '# Writes all querystrings in link...
End if
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top