468,720 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

Select's Qusetion

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

Jul 19 '05 #1
6 1182
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.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Jack" <si*****************@noyahoo.co.jp> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #2
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


"Jack" <si*****************@noyahoo.co.jp> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #3
<%
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

On Mon, 19 Jan 2004 09:48:04 +0900, "Jack"
<si*****************@noyahoo.co.jp> wrote:
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
Jul 19 '05 #4
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

Jul 19 '05 #5

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

On Mon, 19 Jan 2004 13:03:02 +0900, "Jack"
<si*****************@noyahoo.co.jp> wrote:
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
Jul 19 '05 #6
Thank you very much

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JT | last post: by
21 posts views Thread by John Fabiani | last post: by
4 posts views Thread by point | last post: by
1 post views Thread by Carl Wu | last post: by
18 posts views Thread by CJM | last post: by
1 post views Thread by serena.delossantos | last post: by
6 posts views Thread by Apaxe | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.