Forum Moderators: phranque

Message Too Old, No Replies

using onchange with select

using onchange with select

         

bmatth1

8:41 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



I would like eliminate the submit button. The select box is populated dynamically from a database. I would like update a session variable <%session("week_date") with the value in the select box when it changes (onchange="<%session("week_of")=request.querystring("select")%> I cannot get this to work. Any ideas? Here is the original code with the submit button.

Here is the line of code that I am having trouble with:
<select name="select" onchange="<%session("week_date")=Request("select")%>">

<form name="form1" method="get" action="mypage.asp">
Week of
<select name="select">
<!--
<Option value = " " selected></Option>
-->
<%
While (NOT prreqdate.EOF)
%>
<option value="<%=(prreqdate.Fields.Item("prweekof").Value)%>"><%=(prreqdate.Fields.Item("prweekof").Value)%></option>
<%
prreqdate.MoveNext()
Wend
If (prreqdate.CursorType > 0) Then
prreqdate.MoveFirst
Else
prreqdate.Requery
End If
%>
</select>
<input type="submit" name="Submit" value="List Prayer Requests">
</form>

txbakers

11:50 pm on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Even though you don't have a submit button you still need to submit the form.

So, you can do this:

<form action="mypage.asp" method="post name="form1">
<select name="" onChange="document.form1.submit">
<option></option>
</select>
</form>

This will submit your form to the action page when a user changes the select box.

I do this a lot myself also. Users like it.

bmatth1

3:31 pm on Oct 18, 2003 (gmt 0)

10+ Year Member



Can you take a look at this. It still does not seem to work. When the form is submitted, the session variable gets updated, and this displayed in date format, and also is used in a query to the database. This still does not seem to work unless I use the submit button.

<form name="form1" method="post" action="myfile.asp">
Week of
<select name="select" onchange="document.form1.submit">
<!--
<Option value = " " selected></Option>
-->
<%
While (NOT prreqdate.EOF)
%>
<option value="<%=(prreqdate.Fields.Item("prweekof").Value)%>"><%=(prreqdate.Fields.Item("prweekof").Value)%></option>
<%
prreqdate.MoveNext()
Wend
If (prreqdate.CursorType > 0) Then
prreqdate.MoveFirst
Else
prreqdate.Requery
End If
%>
</select>
<input type="submit" name="Submit" value="List Prayer Requests">
</form>

bmatth1

3:45 pm on Oct 18, 2003 (gmt 0)

10+ Year Member



This seems to work with onchange="document.form1.submit()"

Should this be working when I use the call to function format?
Thanks,
Bob