[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-02-16
2
Medium Priority
?
339 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

649 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