SelectedIndex is a read-only property in all browsers except Navigator
3 (O'Reilly's JavaScript: The Definitive Guide).
Yeah, well that's what I get for writing out the code without testing it . . . .
Just change that line to:
form.mySelect[0].selected = true; // Select the first index
The options[] element of the select is an array. Arrays in javascript
begin with 0.
Cutter
Bosky, Dave wrote:
I'm using the onsubmit function to check the length of a form textfield to
verify it contains at least one character.
If the value is less than one character I want to return false and
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!);
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
I'm using the onsubmit function to check the length of a form textfield to
verify it contains at least one character.
If the value is less than one character I want to return false and set the
focus to the first item in a select box.
What am I leaving out?
-
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 ){
to continue. n\nClick
OK!);
form.mySelect.options[0].focus();
return false;
}
return true;
}
Thanks Again.
-Original Message-
From: Scott Brady [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 4:01 PM
To: CF-Talk
Subject: Re: Setting the focus to form select box item
form.mySelect.options[0].focus();
I wasn't even aware you could do that. (I didn't know an option could take a focus, so
I assumed you had to change the select's selected index to be that element and then
focus on the select box).
Cool.
Scott Brady
Scott Brady writes:
form.mySelect.options[0].focus();
I wasn't even aware you could do that. (I didn't know an option could take a focus,
so I assumed you had to change the select's selected index to be that element and
then focus on the select box).
Cool.
erri don't think that
9 matches
Mail list logo