I have written JavaScript code that modifies SELECT.selectedIndex
without problems in NS6.x and IE5+.

Anyway, as for Dave's problem, change:

form.mySelect.options[1].focus();

To:

form.mySelect.options[1].selected = true;
form.mySelect.focus();

OR:

form.mySelect.selectedIndex = 1; // or 0
form.mySelect.focus();

The OPTION object does not have a focus() method in NS JS 1.3 spec.

----------------------------
James Ang
Programmer
MedSeek, Inc.
[EMAIL PROTECTED]




-----Original Message-----
From: Cutter (CF_Talk) [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, December 18, 2002 1:20 PM
To: CF-Talk
Subject: Re: Setting the focus to form select box item.


"SelectedIndex" is a read-only property in all browsers except Navigator

3 (O'Reilly's JavaScript: The Definitive Guide).

Cutter

Scott Brady wrote:

>>function validateForm(form) { 
>>if (form.myText.value.length < 1 ){
>>   alert ('You must select at least one question to continue. n\nClick
>>OK!);
>>   form.mySelect.options[1].focus();
>>   return false;
>>}
>>return true;
>>}
>>    
>>
>
>Try this:
>function validateForm(form) { 
>if (form.myText.value.length < 1 ){
>    alert ('You must select at least one question to continue. n\nClick
>OK!);
>    form.mySelect.selectedIndex = 0; // The first index
>    form.mySelect.focus();
>    return false;
>}
>return true;
>}
>
>Scott
>--------------------------------
>Scott Brady
>http://www.scottbrady.net/
> 
>             
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to