Solved

Classic ASP, Search Recordset on pick list change

Posted on 2016-09-13
1
85 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

724 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