alexandram
asked on
Question on drop down list
How can I implement Disallow First to make sure the first item in the drop down list is never selected?
if you don't want it to get selected, then why put it as an option in the selectbox?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
not the answer but you could color it differently !!
<option style="background-color:#f fffff; color: #33333;"> not selectable </option>
;)
<option style="background-color:#f
;)
Looking forward to your feedback alexandram...
I have a good feeling that my previous comment was very close to the heart of the solution, and am interested to find out if i was correct.
BRUNO
I have a good feeling that my previous comment was very close to the heart of the solution, and am interested to find out if i was correct.
BRUNO
I don't know if Bruno's right, but his solution sounds good.
I usually do the test with CobolDinosaur's function but when the form is submitted, not on the onChange event :
<script type="text/javascript" language="JavaScript">
function fnVerify(theForm)
{
if(document.myForm.mySelec t.selected Index == 0)
{
alert("Please make a selection");
document.myForm.mySelect.f ocus();
return false;
}
return true;
}
</script>
I usually do the test with CobolDinosaur's function but when the form is submitted, not on the onChange event :
<script type="text/javascript" language="JavaScript">
function fnVerify(theForm)
{
if(document.myForm.mySelec
{
alert("Please make a selection");
document.myForm.mySelect.f
return false;
}
return true;
}
</script>
Well I don't see where they are asking for validation; just prevention. If validation is wht is required then Iwould also do it in a function off of the submit, but I think they are just trying to disable the option.
Cd&
Cd&
Then we agree, CobolDinosaur.
When re-reading the question, I'd say you're probably right.
When re-reading the question, I'd say you're probably right.
I like this way:
<SELECT name='mySelect' onChange='this.selectedInd ex=(this.s electedInd ex==0?-1:t his.select edIndex);' >
<SELECT name='mySelect' onChange='this.selectedInd
I can't imagine WHY a solution like yours would be needed Cd&....WHY even have the first option there?
I know at my previous job our first option was always
<option value="">------select one------</option>
we used it to set the width of the select box, but obviously, it shouldn't be a selection when the form is submitted. however, it DOES need to be able to show...
I guess we will have to wait and see what alexandram says.
BRUNO
I know at my previous job our first option was always
<option value="">------select one------</option>
we used it to set the width of the select box, but obviously, it shouldn't be a selection when the form is submitted. however, it DOES need to be able to show...
I guess we will have to wait and see what alexandram says.
BRUNO
<option disabled>disabled</option>
# probably not working for 75% audiance ;-)
# probably not working for 75% audiance ;-)
>>> # probably not working for 75% audiance ;-)
more like 95% ... Netscrap 6, opera and moz1.0 AFAIK
Cd&
more like 95% ... Netscrap 6, opera and moz1.0 AFAIK
Cd&
Netscape 6.x, Mozilla 1.x works
opera 5 and 6 works too, but is strange (you can select, but the selection is not activated, for obvious reason:)
Opera 3 and 4 not yet tested ...
opera 5 and 6 works too, but is strange (you can select, but the selection is not activated, for obvious reason:)
Opera 3 and 4 not yet tested ...
Glad I could help.
graded the solution which works for any browser, even mosaic 0.9
Great!
Great!
<select onChange="if (this.selectedIndex==0) {this.options[1].selected=
<option> first option</option>
<option selected>second option</option>
<option> Third option</option>
<option> Fourth option</option>
<option> fifth option</option>
</select>
Cd&