If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How do you populate 3 text boxes using asp?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-07, 12:55
X-Centric X-Centric is offline
Registered User
 
Join Date: May 2004
Posts: 73
Question 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.
Reply With Quote
  #2 (permalink)  
Old 05-05-07, 03:30
khurram007 khurram007 is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 05-05-07, 03:55
X-Centric X-Centric is offline
Registered User
 
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">
Reply With Quote
  #4 (permalink)  
Old 05-06-07, 09:56
koncept koncept is offline
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old 05-06-07, 11:13
khurram007 khurram007 is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 05-06-07, 21:27
X-Centric X-Centric is offline
Registered User
 
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?
Reply With Quote
  #7 (permalink)  
Old 05-06-07, 21:29
koncept koncept is offline
Registered User
 
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.
Reply With Quote
  #8 (permalink)  
Old 05-06-07, 22:23
X-Centric X-Centric is offline
Registered User
 
Join Date: May 2004
Posts: 73
Thank you guys for steering me in the right direction. I can always count on dbforums.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On