Solved

Classic ASP, Search Recordset on pick list change

Posted on 2016-09-13
1
77 Views
Last Modified: 2016-09-14
I have a classic ASP page that has a list box populated by a record set. The selected Value must be as it is. However, the record set contains another field called 'tel' that I want to use to populate a text box simultaneously. Would have been a simple task if I could change the Value to <%= RS("tel") %>, but I cannot. I need to search the record set based on "first_nm" and "last_nm". How do I do it?
<td>
					<select name="req_pvisitname" >
						<%
							Do Until RS.EOF
						%>
						<option value="<%= RS("first_nm") %> <%= RS("last_nm") %>"><%= RS("last_nm") %>,&nbsp;<%= RS("first_nm") %></option>
						<%	
							RS.MoveNext
							Loop
						%>
					</select>
                    
				</td>

Open in new window

0
Comment
Question by:josephdts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41797153
Test page : https://jsfiddle.net/746vd6eb/

you just need to add a data attribute : data-tel to each option and retrieve it on any change to put the value in a hidden (or not) field :
<td>
       <select name="req_pvisitname" >
       <%
            Do Until RS.EOF
       %>
               <option data-tel="<%= RS("tel") %>" value="<%= RS("first_nm") %> <%= RS("last_nm") %>"><%= RS("last_nm") %>,&nbsp;<%= RS("first_nm") %></option>
       <%	
           RS.MoveNext
           Loop
       %>
       </select>
       <input type="hidden" id="tel" name="tel" />      
</td>

Open in new window


a bit of javascript to put the selected tel in an hidden field with ID and name as "tel"  :

<script>
     document.getElementsByName("req_pvisitname")[0].onchange = function() {
         var selectedOption = this.options[this.selectedIndex];
         var tel = selectedOption.getAttribute("data-tel");
         document.getElementById("tel").value = tel;
     }
</script>
</body>
</html>

Open in new window


please note I put the code in the body at the end
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question