Select's Qusetion

J

Jack

Hello,
<%@ Language=VBScript %>
<%
Response.Write "<FORM name=form1>"
Response.Write "<select name=""select1"">"
Response.Write "<option value=1>One</option>"
Response.Write "<option value=2>Two</option>"
Response.Write "<option value=3>Three</option>"
Response.Write "</select>"
Response.Write "</FORM>"
%>
I want when select1's value change,run a server-side function.
Thank you
 
A

Aaron Bertrand [MVP]

You'll need to submit a form or invoke the server in some way. Client-side
script does not know what the server is; it is merely running code on the
client.
 
R

Ray at

I think you'd have a much easier time differentiating between server side
and client side code/html if you were to break out of the Response.Write
habit for all your straight-up HTML. Drop the ASP'ing out of this
altogether.


<%
''your asp code
%>

<FORM name=form1>
<select name="select1">
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
</select>
</FORM>


See, there's no ASP code there.

Ray at home
 
B

Brynn

<%
Dim theAction: theAction = Request.QueryString("select1")

With Response
Dim optionsArray, zArray, activeOption
optionsArray = Split("0#Select
Action@@1#One@@2#Two@@3#Three", "@@")

.Write "<FORM name=""form1"" type=""get"" action=""?"">"

.Write "<select name=""select1""
onChange=""document.form1.submit()"">"
For n = 0 to ubound(optionsArray)
zArray = Split(optionsArray(n), "#")
activeOption = ""
If theAction = zArray(0) Then: activeOption = "
selected"
.Write "<option value=""" & zArray(0) & """" &
activeOption & ">" & zArray(1) & "</option>"
Next
.Write "</select>"
.Write "</FORM>"
End With

Select Case Request.QueryString("action")
Case "1"
'// some function
Case "2"
'// some function
Case "3"
'// some function
Case Else
'// NO ACTION
End Select
%>



Brynn
www.coolpier.com



Hello,
<%@ Language=VBScript %>
<%
Response.Write "<FORM name=form1>"
Response.Write "<select name=""select1"">"
Response.Write "<option value=1>One</option>"
Response.Write "<option value=2>Two</option>"
Response.Write "<option value=3>Three</option>"
Response.Write "</select>"
Response.Write "</FORM>"
%>
I want when select1's value change,run a server-side function.
Thank you

I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

Brynn
www.coolpier.com
 
J

Jack

Thank you very much,but how can submit form1 when changing select1's value?
<FORM name=form1>
<select name="select1">
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
</select>
</FORM>
I wait anyone's help
 
B

Brynn

Look at my answer in the last post ... this is client-side code.

<select name="select1" onChange="document.form1.submit()">

my code is fully fuctioning ... you can put in a blank page and see it
work ... it even keeps track of which select you are on.

Brynn

Thank you very much,but how can submit form1 when changing select1's value?
<FORM name=form1>
<select name="select1">
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
</select>
</FORM>
I wait anyone's help

I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

Brynn
www.coolpier.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top