|
-
Jan 30th, 2004, 04:37 PM
#1
Thread Starter
Frenzied Member
JS get option value
I have the current lists obj in
tempobj
I want to get its value, of the selected item.
so I tried
tempobj.option(tempobj.selectedIndex)
and
tempobj.list(tempobj.selectedIndex)
How do I get that?
-
Jan 30th, 2004, 05:36 PM
#2
Array indexing in JavaScript (as in any other C-syntax language) uses [], so it's
tempobj.options[tempobj.selectedIndex]
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2004, 05:39 PM
#3
Thread Starter
Frenzied Member
ah I see. thanks alot beeee
-
Jan 30th, 2004, 05:42 PM
#4
Thread Starter
Frenzied Member
do capitals matter in java?
-
Jan 30th, 2004, 05:42 PM
#5
Thread Starter
Frenzied Member
cause they really do in perl, and that is an annoyance
-
Jan 30th, 2004, 05:48 PM
#6
Thread Starter
Frenzied Member
How come this doesnt work?
(if the list has '' in the selected item, I want it to speak up)
<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {if (((tempobj.type=='text'||tempobj.type=='textarea')&&tempobj.value=='')||(tempobj.type.toString(0)==' s'&&tempobj.options[tempobj.selectedIndex].value=='')) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the all required fields are completed.");
return false;
}
else
return true;
}
// End -->
-
Jan 30th, 2004, 06:01 PM
#7
First, remove the Begin and End words, especially the Begin, it might confuse some engines.
Second, capitalization matters in JavaScript (again, like in most C-like languages, the only exception I know is PHP), so you'd better get used to it. It's really not that bad.
Third:
tempobj.type.toString(0)=='s'
That's invalid code. type is already a string, so toString doesn't do anything. And toString doesn't take arguments. I guess what you want is
tempobj.type[0], right?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2004, 06:45 PM
#8
Thread Starter
Frenzied Member
oh interesting. thanks ill try that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|