473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dynamic Select and onChange

I have a Dynamic drop-down box that is populated based on a ADO query.
This works fine. I want to capture the users selection and assign it to
a variable for use in another query. I am using the onChange event to
try and capture the users selection but it always passes the last entry
in the drop-down list not what the user selects. Can anyone help me
with this. I am very new to ASP\Jscript\Vbscript. A snippent of the
code is below.

<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>

Dec 13 '06 #1
3 6816
Michael McGrew wrote:
I have a Dynamic drop-down box that is populated based on a ADO query.
This works fine. I want to capture the users selection and assign it
to a variable for use in another query. I am using the onChange event
to try and capture the users selection but it always passes the last
entry in the drop-down list not what the user selects. Can anyone
help me with this. I am very new to ASP\Jscript\Vbscript. A snippent
of the code is below.

<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>
This is not really an ASP issue (you'd be having the same problem if
your file had a .htm extension instead of .asp, wouldn't you?): it's a
client-side scripting issue. You haven't shown us enough here to allow
us to reproduce your problem. When you post to the client-side scripting
group (microsoft.public.scripting.jscript) include the setMgr function
code. Also, run your page and View source so you can include the html
for the options in the select element.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Dec 13 '06 #2

Bob Barrows [MVP] wrote:
Michael McGrew wrote:
I have a Dynamic drop-down box that is populated based on a ADO query.
This works fine. I want to capture the users selection and assign it
to a variable for use in another query. I am using the onChange event
to try and capture the users selection but it always passes the last
entry in the drop-down list not what the user selects. Can anyone
help me with this. I am very new to ASP\Jscript\Vbscript. A snippent
of the code is below.

<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>

This is not really an ASP issue (you'd be having the same problem if
your file had a .htm extension instead of .asp, wouldn't you?): it's a
client-side scripting issue. You haven't shown us enough here to allow
us to reproduce your problem. When you post to the client-side scripting
group (microsoft.public.scripting.jscript) include the setMgr function
code. Also, run your page and View source so you can include the html
for the options in the select element.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
The setMgr function is just simple javascript to set a variable.

function setMgr(curMgr) {
var sMgr = curMgr;
}

I get the variable but it is always the last item in the drop-down
select, it doesn't reflect the selection.

Dec 13 '06 #3

"Michael McGrew" <mc************@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
>
Bob Barrows [MVP] wrote:
Michael McGrew wrote:
I have a Dynamic drop-down box that is populated based on a ADO query.
This works fine. I want to capture the users selection and assign it
to a variable for use in another query. I am using the onChange event
to try and capture the users selection but it always passes the last
entry in the drop-down list not what the user selects. Can anyone
help me with this. I am very new to ASP\Jscript\Vbscript. A snippent
of the code is below.
>
<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>
This is not really an ASP issue (you'd be having the same problem if
your file had a .htm extension instead of .asp, wouldn't you?): it's a
client-side scripting issue. You haven't shown us enough here to allow
us to reproduce your problem. When you post to the client-side scripting
group (microsoft.public.scripting.jscript) include the setMgr function
code. Also, run your page and View source so you can include the html
for the options in the select element.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

The setMgr function is just simple javascript to set a variable.

function setMgr(curMgr) {
var sMgr = curMgr;
}

I get the variable but it is always the last item in the drop-down
select, it doesn't reflect the selection.
All the option values are "" so I'm surprised you are getting any value at
all.
Dec 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
4
by: PM ArunKumar | last post by:
i have two dropdown list in my form where the values in the list of second drop down changes based on the value i select in the first dropdown.(very similar to country and states list), here after...
1
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem,...
0
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value &...
0
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value &...
0
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value &...
1
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.