Solved

Classic ASP - Function to check that the user has selected a value

Posted on 2011-02-16
2
331 Views
Last Modified: 2012-05-11
I am trying to update one of my asp pages so that it forces the user to select a value in a drop down list box. Currently it defaults to one of the values but users then never change it, I would like to force them to choose one.

What is the easiest simplest way to do this?


<td align="right" nowrap>when would you like us to call you?&nbsp;&nbsp;</td>
                  <td align="left"> <select class="inputfield" name="TimeRequired">
                      <!--<option value="0" <%if Cstr(callerRequestTime) = "0" then response.write("selected")%>>Immediately!</option>-->
			<option value="15" <%if Cstr(callerRequestTime) = "15" then response.write("selected")%>>in 
                      15 minutes</option>
                      <option value="30" <%if Cstr(callerRequestTime) = "30" then response.write("selected")%>>in 
                      30 minutes</option>
                      <option value="60" <%if Cstr(callerRequestTime) = "60" then response.write("selected")%>>in 
                      one hour</option>
                    </select> </td>

Open in new window

0
Comment
Question by:Lico_w
[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
2 Comments
 
LVL 20

Accepted Solution

by:
Proculopsis earned 250 total points
ID: 34905028

Are you after something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q__26824839.html</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

jQuery(document).ready( function () {

  var original = $("#TimeRequired>option:selected").val();

  $("#postback").click( function() {
    $("#error").empty();
    if ( original == $("#TimeRequired>option:selected").val() ) {
      $("#error").text( "Error: please select another time." ).css( { color: "#f00" } );
    }
  });

});

</script>
</head>
<body>

<select id="TimeRequired">
  <option value="0">Immediately!</option>
  <option value="15">in 15 minutes</option>
  <option value="30" selected="true">in 30 minutes</option>
  <option value="60">in one hour</option>
</select>

<input id="postback" type="button" value="Postback">

<span id="error"></span>

</body>
</html>

Open in new window

0
 
LVL 10

Assisted Solution

by:John Claes
John Claes earned 250 total points
ID: 34905044
add a option "[Select]" with value -10
Make this the first and default value of the dropdown.

This ensures that the user sees that he must change the dropdown. and you can check if he did ;-)

regards

poor beggar
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

Title # Comments Views Activity
Create a Dropdown list with sub group 10 43
allow link tag to be submit like form 15 60
Where is this content coming from? 4 40
close window in firefox 3 37
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 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