controling if the user has slected one option or no

M

[Miren]

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
 
K

ksadmin

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
(e-mail address removed)

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

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

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top