Dynamic Select and onChange

Discussion in 'Javascript' started by Michael McGrew, Dec 13, 2006.

  1. 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>
     
    Michael McGrew, Dec 13, 2006
    #1
    1. Advertising

  2. Michael McGrew

    ASM Guest

    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
     
    ASM, Dec 13, 2006
    #2
    1. Advertising

  3. 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
    %>
     
    Michael McGrew, Dec 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders S. Clausen
    Replies:
    3
    Views:
    55,391
    ranjithchinnasamy83
    Jan 5, 2009
  2. Michael McGrew

    Dynamic Select and onChange

    Michael McGrew, Dec 13, 2006, in forum: ASP General
    Replies:
    3
    Views:
    298
    Anthony Jones
    Dec 14, 2006
  3. Covad
    Replies:
    1
    Views:
    205
    Richard Cornford
    Nov 3, 2003
  4. palmiere
    Replies:
    1
    Views:
    431
    Erwin Moller
    Feb 9, 2004
  5. yawnmoth

    onchange event handler and select tags

    yawnmoth, Dec 11, 2007, in forum: Javascript
    Replies:
    5
    Views:
    194
    Thomas 'PointedEars' Lahn
    Dec 12, 2007
Loading...

Share This Page