Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Options in Drop down box

Reply
Thread Tools

Options in Drop down box

 
 
Paul BRYAN
Guest
Posts: n/a
 
      12-02-2003
Hi

I'm using IE to create a form that includes a drop down box and a submit
button .

The drop down box contains a number of options, but one of the options is no
longer available.

If the unavailable option is chosen and the submit button is pressed, how do
I get a pop up box to appear telling the user the option is no longer
available.

Hope this makes sense


Paul


 
Reply With Quote
 
 
 
 
brucie
Guest
Posts: n/a
 
      12-02-2003
in post <news:sSYyb.1390$>
Paul BRYAN said:

> If the unavailable option is chosen and the submit button is pressed, how do
> I get a pop up box to appear telling the user the option is no longer
> available.


the only reliable way to do it would be to either remove the option
server side so its not there to be selected or check if an option is no
longer valid when the form is submitted and return an error message. you
could use a bit of JS to pop up an alert but you'll still need to do the
server side checking.

--
brucie
02/December/2003 07:35:50 pm kilo
 
Reply With Quote
 
 
 
 
Steve R.
Guest
Posts: n/a
 
      12-02-2003
Paul BRYAN wrote in message ...
> The drop down box contains a number of options, but one of the options is no
> longer available.


Surely the most "User-Friendly" action is to remove the option itself. LOL.

Steve.


 
Reply With Quote
 
Louis Somers
Guest
Posts: n/a
 
      12-02-2003
"Paul BRYAN" <> wrote in
news:sSYyb.1390$:

Like others say, best is to remove the option, but if you insist, here is
some javascript that will alert the yser (but not prevent).

<html><head>
<script type="text/javascript" language="JavaScript">
function CheckAvail(theForm)
{
var mytext = theForm.selection.value;
if (mytext == 's002') {
alert('potatoes have been sold out');
theForm.thetext.focus();
}
}
</script>
<title>limit chars</title>
</head>
<body>
<form method="post" action="yoururl" id="myForm">
<select name="selection" onChange="CheckAvail(myForm);">
<option value="s001">flowers
<option value="s002">potatoes
<option value="s003">cheese
<option value="s004">beans
</select>
</form>
</body></html>


--
News Updater, No scripts, No Database
http://www.xmlssoftware.com/NUpdater
 
Reply With Quote
 
Olaf Studt
Guest
Posts: n/a
 
      12-03-2003
Louis Somers wrote:
>
> Like others say, best is to remove the option, but if you insist, here is
> some javascript that will alert the yser (but not prevent).
> [...]
> <form method="post" action="yoururl" id="myForm">
> <select name="selection" onChange="CheckAvail(myForm);">
> [options]
> </select>
> </form>


Another possibility is

<form ... onSubmit="return myFunc();">

where, if myFunc returns false , the submission is
cancelled - _*IF*_ the user has enabled JavaScript!

--
Olaf from THE Hamburg (not home of hamburgers)
Replace laundry basket by my last name to avoid ending up in such.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Drop down selext box options using external JS not working in IE sewerized@hotmail.com Javascript 3 08-11-2006 07:57 PM
tooltip for the options of a drop down list box nagesh Javascript 1 04-23-2005 01:21 AM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57