473,388 Members | 1,375 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,388 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
2 1773
ASM
Michael McGrew a écrit :
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.
not normal ! your code seems good.

what does setMgr() ?

wouldn't be your asp which create wrong values ?
did you look at html code of displayed page ?
<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 13 '06 #2

ASM wrote:
Michael McGrew a écrit :
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.

not normal ! your code seems good.

what does setMgr() ?

wouldn't be your asp which create wrong values ?
did you look at html code of displayed page ?
<select name="cur_mgr"
onchange="setMgr(this.options[this.selectedIndex].value);">
<option value=""></option>
<%=Manager%>
</select>


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
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.

I then use this variable in another ADO query:

<%
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
Set objRootDSE = GetObject("LDAP://rootDSE")
strRootDSE = objRootDSE.Get("defaultNamingContext")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://" & strRootDSE & ">;(&(objectCategory=User)" & _
"(CN=" & sMgr & "));department;subtree"
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strDept = objRecordset.Fields("sAMAccountName").Value
Department = Department & "<option value='" & strDept & "'>" &
strDept & "</option>"
objRecordSet.MoveNext
Loop
%>

Dec 13 '06 #3

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.