Solved

Classic ASP, Search Recordset on pick list change

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

840 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