hello. i have a really simple form that asks the user to select a
Month from a dropdown. the first time a user visits the page, the
highlighted option should be October, which works fine. then, if the
user submits the form, i want the dropdown to highlight whatever
selection that the user made in the resulting page. for example, if
the user chose February, then the code in the resulting page would look
something like <option value="February " selected>.
here's my code:
<%
dim queryMonth
if (Request.querys tring("eventMon th") <"" ) then
queryMonth = Request.queryst ring("eventMont h")
else
queryMonth = Month(Now())
end if
%>
<form action="events_ new.asp" method="get" onSubmit="retur n
checkRequiredFi elds(this);">
<select name="eventMont h">
<option value="">-- Month --</option>
<%
dim i
for i = 1 to 12
if (i = queryMonth) then
response.Write( "<option value='" & i & "' selected>" & MonthName(i)
& "</option>")
else
response.Write( "<option value='" & i & "'>" & MonthName(i) &
"</option>")
end if
next
%>
</select>
<input type="submit" value="Go">
</form>
However, after performing some tests, i'm not getting the effect that i
want. It only works the first time I visit the page. otherwise, if i
submit the form, the "selected" entry in the dropdown is always the
first option <option value="">--Month--</option>. Anyone know what's
going on? Thanks 7 2410
Did you try basic debugging? Like,
response.write queryMonth
? Did you try making sure you were comparing apples to apples, like
if (clng(i) = clng(queryMonth ))
?
<br**********@g mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
hello. i have a really simple form that asks the user to select a
Month from a dropdown. the first time a user visits the page, the
highlighted option should be October, which works fine. then, if the
user submits the form, i want the dropdown to highlight whatever
selection that the user made in the resulting page. for example, if
the user chose February, then the code in the resulting page would look
something like <option value="February " selected>.
here's my code:
<%
dim queryMonth
if (Request.querys tring("eventMon th") <"" ) then
queryMonth = Request.queryst ring("eventMont h")
else
queryMonth = Month(Now())
end if
%>
<form action="events_ new.asp" method="get" onSubmit="retur n
checkRequiredFi elds(this);">
<select name="eventMont h">
<option value="">-- Month --</option>
<%
dim i
for i = 1 to 12
if (i = queryMonth) then
response.Write( "<option value='" & i & "' selected>" & MonthName(i)
& "</option>")
else
response.Write( "<option value='" & i & "'>" & MonthName(i) &
"</option>")
end if
next
%>
</select>
<input type="submit" value="Go">
</form>
However, after performing some tests, i'm not getting the effect that i
want. It only works the first time I visit the page. otherwise, if i
submit the form, the "selected" entry in the dropdown is always the
first option <option value="">--Month--</option>. Anyone know what's
going on? Thanks
<br**********@g mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
hello. i have a really simple form that asks the user to select a
Month from a dropdown. the first time a user visits the page, the
highlighted option should be October, which works fine. then, if the
user submits the form, i want the dropdown to highlight whatever
selection that the user made in the resulting page. for example, if
the user chose February, then the code in the resulting page would look
something like <option value="February " selected>.
here's my code:
<%
dim queryMonth
if (Request.querys tring("eventMon th") <"" ) then
queryMonth = Request.queryst ring("eventMont h")
else
queryMonth = Month(Now())
end if
%>
<form action="events_ new.asp" method="get" onSubmit="retur n
checkRequiredFi elds(this);">
<select name="eventMont h">
<option value="">-- Month --</option>
<%
dim i
for i = 1 to 12
if (i = queryMonth) then
response.Write( "<option value='" & i & "' selected>" & MonthName(i)
& "</option>")
else
response.Write( "<option value='" & i & "'>" & MonthName(i) &
"</option>")
end if
next
%>
</select>
<input type="submit" value="Go">
</form>
However, after performing some tests, i'm not getting the effect that i
want. It only works the first time I visit the page. otherwise, if i
submit the form, the "selected" entry in the dropdown is always the
first option <option value="">--Month--</option>. Anyone know what's
going on? Thanks
<select name="eventMont h">
<option value="">-- Month --</option>
<%
dim i
for i = 1 to 12
Response.Write "<option value='" & i & "'"
If i = Cint(queryMonth ) Then Response.Write " selected"
Response.Write ">" & MonthName(i) & "</option>" & vbcrlf
next
%>
</select>
--
Mike Brind
wrote on 12 okt 2006 in microsoft.publi c.inetserver.as p.general:
hello. i have a really simple form that asks the user to select a
Month from a dropdown. the first time a user visits the page, the
highlighted option should be October, which works fine. then, if the
user submits the form, i want the dropdown to highlight whatever
selection that the user made in the resulting page. for example, if
the user chose February, then the code in the resulting page would look
something like <option value="February " selected>.
Something like this comes from one of my pages:
<select name='theSelect ion'
style='backgrou nd-color:#ebddb0;c olor:#826729;'>
<%
for n=0 to to ubound(optionAr ray)-1
if request.form("t heSelection") = optionArray(n) then
selec = " selected style='color:#c 00;background-color:#fbedc0;' "
else
selec = ""
end if
%>
<option value='<%=optio nArray(n)%>'<%= selec%>><%=opti onArray(n)%></option>
<%
next
%>
</select>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
i did a CInt on queryMonth, and that worked perfectly. thanks to all.
>Did you try making sure you were comparing apples to apples, like if (clng(i) = clng(queryMonth ))
just one lingering question though...in the code below, since i'm
basically performing the same test, why would this work and not my
actual code? thanks
<%
if (1 = "1") then
response.Write( "asdf") //result is this line of code
else
response.Write( "rarr")
end if
%>
<br**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
>i did a CInt on queryMonth, and that worked perfectly. thanks to all.
>>Did you try making sure you were comparing apples to apples, like if (clng(i) = clng(queryMonth ))
just one lingering question though...in the code below, since i'm
basically performing the same test, why would this work and not my
actual code? thanks
<%
if (1 = "1") then
response.Write( "asdf") //result is this line of code
else
response.Write( "rarr")
end if
%>
Because items in the the Request collections are passed as strings. That's
what Aaron meant by comparing apples with apples. You were comparing a
numeric type with a string.
If you ever get stuck on what datatype a variable is, just Response.Write
TypeName(variab le).
--
Mike Brind
It's not the same test. You implicitly defined both constants here. In
your original code, you brought in a string from the request collection
(this is NOT implicitly declared) and compared it to something that had been
explicitly cast as a number due to the for loop.
<br**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
>i did a CInt on queryMonth, and that worked perfectly. thanks to all.
>>Did you try making sure you were comparing apples to apples, like if (clng(i) = clng(queryMonth ))
just one lingering question though...in the code below, since i'm
basically performing the same test, why would this work and not my
actual code? thanks
<%
if (1 = "1") then
response.Write( "asdf") //result is this line of code
else
response.Write( "rarr")
end if
%> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathaniel Maier |
last post by:
Hi. How can I send form results to an email address based on what the user
selects? e.g. not to the same address all the time, and not to all
addresses, but to the one that the user selects. How can I refer to that?
Thanks for the help.
Nathaniel Maier
email/MSNmsg: nmaier@columbus.rr.com
AIM: OSUKid7
|
by: Shaiboy_UK |
last post by:
Hi All,
Hope someone can help here!!
I'm putting a standard mail page together, that will allow my users to
sent templete emails out to people. The files are stored in text
files. I have come up with a script to produce the names into a
Select list, but know i'm wanting them to be read into a textarea box,
to allow me to submit them into from the form into the sendmail.asp
page! but the only way i can pass them out, is into a...
|
by: Dan |
last post by:
Can anyone offer suggestions on how to do this or if it is possible?
I have a form that uses a drop down box and 2 text fields.
What I am trying to do is have the value of each text box set by the
choice from the drop down box.
Something like:
<form name="populatefrm" id="contactfrm" method="post"
|
by: Raffi |
last post by:
Hi folks,
I'm new to JavaScript and need some help.
I have a form with a select field. Depending on what is selected in
this field, I want to display or not display another select field. For
example first field asks the user if they drive, if the user selects
"NO" the form doesn't change. If they select "YES", another field
appears with different makes to chose from. If they change back to "NO"
the second field dissapears again.
|
by: iam247 |
last post by:
Hi
I have an ASP form which only includes an option list. The list is
dynamically created but includes a default value, which is an
instruction "Select a group".
The code is shown at bottom.
I want to ensure the user does not submit the form with the default
value selected.
| |
by: sparksol |
last post by:
I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display.
I would like to keep the textbox(es) and the submit button showing until another option is selected. Also the data that's submitted is showing on the form page.
Here's an example - I need the code below to do this:
1. I go to the page - I see a drop down box.
2. I...
|
by: nomad |
last post by:
Hello Everyone:
I'm working on a project for a client in which they want to add and delete events for a selected day on a calendar.
I have built the calendar and added the events, but I'm having troubles deleting the event.
I thought I could use the same code for adding the event and change some of the code.
I get this error when doing so
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version...
|
by: jerrydigital |
last post by:
Hello,
I have an edit user page that allows the user to view their user information and make changes if possible. I have a simple html login page that directs to an asp page called edituser.asp when they login. Here is the edituser.asp code I have
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual="/adovbs.inc"-->
<html>
<body>
<%
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |