Forum Moderators: open

Message Too Old, No Replies

Simple Drop Down List

Need to prevent message appearing first

         

The Cricketer

12:50 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



The code below simply displays a message when a certain <option> is selected from the dropdown menu. The only problem I have is that when the page loads to begin with, it displays 'No meetings for you to attend!' even before anything is selected. Is there any way I can prevent this?


<html><head>
<TITLE>FormListBoxRespond.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form action="FormListBoxRespond.asp" method="post">
<SELECT NAME="state">
<OPTION SELECTED VALUE="md">Maryland</OPTION>
<OPTION value="dc">District of Columbia</OPTION>
<OPTION value="va">Virginia</OPTION>
<OPTION value="whoknows">Somewhere Else!</OPTION>
</SELECT>
<input type=submit value="Choose State">
</form>
</body></html>

<%mystate = request.form("state")
Select Case ucase(mystate)
case "DC"
response.write "DC meeting on 15th"
case "MD"
response.write "MD meeting on 20th"
case else
response.write "No meetings for you to attend!"
End Select%>

korkus2000

2:45 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a selected option that will do nothing. I think that will be the easiest way.

You could also use an if statement.

If mystate <> "" Then

code

End If

The Cricketer

4:39 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



oh dear korkus2000, I'm struggling. When this code is combined within one .asp file (which i want) I just can't get it to work as i described earlier. What am i doing wrong? I've even tried both of your suggested methods, the first one's below. Maybe it's better to start again, i'm getting confused on what seems a simple task. There probably isn't a message appearing when the page loads but it's still not working smoothly, any advice?

I suppose I would prefer to use IF statements, but i can't get that to work either!


<html><head>
<TITLE>FormListBoxRespond.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form action="FormListBoxRespond.asp" method="post">
<SELECT NAME="state">
<OPTION SELECTED VALUE="select">SELECT</OPTION>
<OPTION VALUE="md">Maryland</OPTION>
<OPTION value="dc">District of Columbia</OPTION>
<OPTION value="va">Virginia</OPTION>
<OPTION value="whoknows">Somewhere Else!</OPTION>
</SELECT>
<input type=submit value="Choose State">
</form>
</body></html>

<%mystate = request.form("state")
Select Case ucase(mystate)
case "SELECT"
response.write ""
case "MD"
response.write "MD meeting on 20th"
case "DC"
response.write "DC meeting on 15th"
case else
response.write "No meetings for you to attend!"
End Select%>

too much information

5:02 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:
<%
if request.form("state") <> "" then
mystate = request.form("state")
Select Case ucase(mystate)
case "SELECT"
response.write ""
case "MD"
response.write "MD meeting on 20th"
case "DC"
response.write "DC meeting on 15th"
case else
response.write "No meetings for you to attend!"
End Select
else
response.write "Please Select"
end if
%>

The first time around there is no selection from the request.form so it will do the last (Please Select) line.

The Cricketer

3:31 pm on Feb 10, 2004 (gmt 0)

10+ Year Member



I've only recently returned to this subject after doing some other things and have attempted to use the code you suggested again 'too much information'.

This time it works, it probably worked when I used your code last time, but I was getting a bit confused with the browser's refresh.

So thanks again, it now works!