select ID in drop down list and show name in text box without clicking submit button

Discussion in 'ASP General' started by Matthew Louden, Jan 9, 2004.

  1. if the user select the EmployeeID in drop down list, and then click the
    submit button, and it will look up database and show the Employee Name in
    the text box, this is easy.

    But my case is: when the user select the employeeid in drop down list, it
    will
    fire the onchange event, and then look up database and show the employee
    name in the text box. There is no submit button.

    I really have no idea how to do that.
     
    Matthew Louden, Jan 9, 2004
    #1
    1. Advertisements

  2. Matthew Louden

    Ray at Guest

    Use client-side code to trigger a reload of the page.

    <select onchange="location.href='thispage.asp?id='+this.value">


    <%

    Dim iSelectedID, sName
    iSelectedID = Request.Querystring("id")
    If iSelectedID <> "" Then
    sSQL = "SELECT theName FROM theTable WHERE theID=" & iSelectedID"
    'etc.
    %>

    Ray at work
     
    Ray at, Jan 9, 2004
    #2
    1. Advertisements

  3. Thanks Ray, Now I am able to get the name corresponding to the id selected
    by the user.

    But now to put the name printed in the text box? the following is javascript
    again, and I put inside <% %> and it wont work.

    document.eventform.empname.value = objRS("FirstName")


    please help.
     
    Matthew Louden, Jan 9, 2004
    #3
  4. Matthew Louden

    Ray at Guest

    <input type="text" value="<%=objRS.Fields.Item(0).Value%>">

    Ray at work
     
    Ray at, Jan 9, 2004
    #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.