Options in Drop down box

P

Paul BRYAN

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
 
B

brucie

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.
 
S

Steve R.

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.
 
L

Louis Somers

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>
 
O

Olaf Studt

Louis said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top