Dynamic Select and onChange

Discussion in 'ASP General' 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. Advertisements

  2. 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.
     
    Bob Barrows [MVP], Dec 13, 2006
    #2
    1. Advertisements

  3. 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.
     
    Michael McGrew, Dec 13, 2006
    #3
  4. All the option values are "" so I'm surprised you are getting any value at
    all.
     
    Anthony Jones, Dec 14, 2006
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.