Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    73

    Question Unanswered: How do you populate 3 text boxes using asp?

    I have a dropdown combo box that pulls a company name out of a database. I can fill a textbox with that company name with an onchange event. But what I dont understand is how to fill 3 more text boxes with the address city and state of the company that was selected.

  2. #2
    Join Date
    Apr 2007
    Posts
    29
    It should be pretty straight forward. Populate all text boxes the same way you are doing with the first. However, I might help if you could post the code.

    Khurram.

  3. #3
    Join Date
    May 2004
    Posts
    73

    Question

    Here is my code. I would like to put the shipping address, shipping city, shipping state and zip code in their own boxes based on the dropdown. Im thinking I need a function since its more than one texbox? And use the selected index somehow? I dont know how to query the related fields in the dropdown.



    <%SQL = "SELECT CUSTOMER_ID,CUSTOMER_SHIPPING_ADDRESS,CUSTOMER_SHI PPING_CITY,CUSTOMER_SHIPPING_STATE,CUSTOMER_SHIPPI NG_ZIP_CODE FROM TBL_CUSTOMER WHERE CUSTOMER_TYPE_ID = 'Master Distributor'"
    rs.open SQL, Conn%>
    <select name="cid" onChange="document.form.companyname.value=this.val ue">
    <option SELECTED><%Response.Write(Request.Cookies("cid"))% >
    <%Do While Not rs.EOF%>
    <option value="<%=rs("CUSTOMER_ID")%>"><%=rs("CUSTOMER_ID" )%></option>
    <%rs.movenext%><%loop%><%rs.close%>
    </select>
    </td>
    <td>
    <input name="companyname" value="" size="40" maxlength="40">
    <input name="saddress" value="" size="40" maxlength="40">
    <input name="scity" value="" size="40" maxlength="40">
    <input name="sstate" value="" size="40" maxlength="40">
    <input name="szipcode" value="" size="40" maxlength="40">

  4. #4
    Join Date
    Jul 2006
    Posts
    26
    you cannot mix javascript and asp easily to do this. the support for things like this is built into asp.net and can be done very easily.

    if you want to do this you will need some javascript arrays to hold all the fields you want to populate and then when an onchange does occur reference those arrays to get your data. the reason you cannot use asp is because it runs server side before sending the page to the client where the javascript will run

  5. #5
    Join Date
    Apr 2007
    Posts
    29
    Quote Originally Posted by koncept
    you cannot mix javascript and asp easily to do this. the support for things like this is built into asp.net and can be done very easily.

    if you want to do this you will need some javascript arrays to hold all the fields you want to populate and then when an onchange does occur reference those arrays to get your data. the reason you cannot use asp is because it runs server side before sending the page to the client where the javascript will run
    Cent percent correct.

  6. #6
    Join Date
    May 2004
    Posts
    73
    You know, I never thought of it like that. But now that you have explained it to me it makes perfect sense. I was so focused on the task at hand and didnt think it through logically.

    However the application needs to remain in classic asp. A solution might be and tell me if you guys think this will work. Perform and onchange to refresh the page to simulate a post back, then send the value of the dropdown to an sql WHERE clause to return the other fields of that specific record. After the results are in, put them in the text boxes. Maybe?

  7. #7
    Join Date
    Jul 2006
    Posts
    26
    that is basicaly what asp.net does when you use its procedures so yes it should work just fine.

  8. #8
    Join Date
    May 2004
    Posts
    73
    Thank you guys for steering me in the right direction. I can always count on dbforums.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •