Solved

Classic ASP, Search Recordset on pick list change

Posted on 2016-09-13
1
39 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now