Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Dynamic Select and onChange

Reply
Thread Tools

Dynamic Select and onChange

 
 
Michael McGrew
Guest
Posts: n/a
 
      12-13-2006
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>

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      12-13-2006
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
 
Reply With Quote
 
 
 
 
Michael McGrew
Guest
Posts: n/a
 
      12-13-2006

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
%>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<HTML:SELECT onChange="onSelection();"> HELP!!!!!! Anders S. Clausen Java 3 01-05-2009 08:13 AM
onchange event handler and select tags yawnmoth Javascript 5 12-12-2007 08:19 PM
Dynamic Select and onChange Michael McGrew ASP General 3 12-14-2006 12:14 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
dynamic select element: problem with onchange event Covad Javascript 1 11-03-2003 02:02 AM



Advertisments