Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force choice from drop-down

Status
Not open for further replies.

gwilym40

Programmer
May 2, 2002
31
GB
I have an asp form with various drop-downs
if the user chooses no it locks the drop-down, if they choose yes it enables the drop-down choices, example as below.
If the user chooses Yes, how do I force the user to choose from the drop-down?
regards
gwilym


function disableIt(Field)
{
//Set the disabled property to true and clear the field contents
Field.disabled = true;
Field.value = "";
}

function enableIt(Field)
{
Field.disabled = false;
}

function extracheck(Field)
{
return !Field.disabled;
}

<TR><TD><font face=&quot;Arial&quot;>Yes:</TD><TD><INPUT TYPE=&quot;radio&quot; NAME=&quot;Section7_NewAccess&quot; VALUE=&quot;Yes&quot; CHECKED onClick=&quot;enableIt(document.HouseApp3.Section7_NewAccessType);&quot;></TD><TD><SELECT NAME=&quot;Section7_NewAccessType&quot; onClick=&quot;return extracheck(this)&quot;><OPTION><OPTION>Vehicular<OPTION>Pedestrian</SELECT></TD></TR>

<TR><TD><font face=&quot;Arial&quot;>No:</TD><TD><INPUT TYPE=&quot;radio&quot; NAME=&quot;Section7_NewAccess&quot; VALUE=&quot;No&quot; onClick=&quot;disableIt(document.HouseApp3.Section7_NewAccessType);&quot;></TD></TR>
 
Do some javascript validation OnSubmit, make the primary option have a value = &quot;&quot; and test for this, if the field is blank then sto the submit and alert the user to choose a value...

function validate()
{
if document.form.bodyColour.value = &quot;&quot; {
alert(&quot;Please choose a item from the list&quot;);
return false;
}

hth

Bastien Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top