Solved

Classic ASP, Search Recordset on pick list change

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
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…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

773 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