471,091 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

controling if the user has slected one option or no

Hello i have one great problem with one form.
i must to know, for submmiting the form, if the user, has change the
select, has select one or no.
in my select i have:

<select name="maquina" >
<option selected="selected" value="0">Elige una opcion</option>
<option value="4">asdfasdf</option>
<option value="5">asdfasdfasdf</option>
</select>

if the selectd value is 0 the user has not select, if isn't 0 the user has
selected one option, in this case the form is submmited.
how can i controle this problemm using javascript?
do you have one sample?
can you help me?
thnaks
Jul 23 '05 #1
1 1265
On Fri, 14 May 2004 23:09:34 +0200, "[Miren]"
<bo**********@excite.com> wrote:
Hello i have one great problem with one form.
i must to know, for submmiting the form, if the user, has change the
select, has select one or no.
in my select i have:

<select name="maquina" >
<option selected="selected" value="0">Elige una opcion</option>
<option value="4">asdfasdf</option>
<option value="5">asdfasdfasdf</option>
</select>

if the selectd value is 0 the user has not select, if isn't 0 the user has
selected one option, in this case the form is submmited.
how can i controle this problemm using javascript?
do you have one sample?
can you help me?
thnaks


here is a sample of some code i have been working on for a project.
Hope it helps you out some. I'm not sure it's the most efficent method
but it works. I have the JavaScript portion as a part of a validation
function that run OnSubmit.

Let me know if you have any more problems

Josh Austin
System Admin
Agent Services of America
ks*****@comcast.net

<script language="JavaScript" type="text/javascript">
<!--
//JavaScript section (modify this using your form name in place of
//theForm and your field name in place of Dproduct
//Place an error message to be displayed to the user in place
//of Please select a product.......
function Form1_Validator(theForm)
{

// Check if no drop down or the default drop down was selected
if (theForm.Dproduct.selectedIndex <= 0)
{
alert("Please select a product type from the drop down list.");
theForm.Dproduct.focus();
return (false);
}

-->

<!--Html Section-->
<!--I put the html section here for your reference-->
<SELECT size="1" name="Dproduct">
<option value="0" selected>
Please Select One...
<option value="10">
10 Year Term
<option value="15">
15 Year Term
<option value="20">
20 Year Term
<option value="25">
25 Year Term
<option value="30">
30 Year Term
<option value="SV">
Survivorship
<option value="UP">
Universal Life w/LPT
<option value="UL">Universal Life</option>
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.