|
-
Jan 18th, 2001, 01:42 AM
#1
Thread Starter
Hyperactive Member
Hello,
I have this jscript function which works perfectly in IE, but not in Netscape. When I click the submit button in NS - nothing happens - no error, no "do you want to debug" - nothing.
Here's the function... it just checks what was selected in a dropdown(lstcountry) and then loads some page accordingly.
My submit button code is just something like
<input type="button" onclick="submitit()"
function submitit() {
// get country
var sCountry = new String(document.frmcountry.lstcountry.value.substring(0,1).toUpperCase());
var sActionPage = new String();
// determine which page to send form to
if (sCountry == "*") {
sActionPage = "city.asp";
} else {
sActionPage = "province.asp";
}
// set form action
document.frmcountry.action = sActionPage;
// submit form
document.frmcountry.submit();
return;
}
</script>
-
Jan 18th, 2001, 06:26 AM
#2
Fanatic Member
Hi turfbult.
Unfortantlely the way you access the current value of the listbox only works in ie and and not MS. you need to use a slightly more complicated line for it to work in both and is as follows
Code:
var sCountry = new String(document.frmcountry.lstcountry.options[document.frmcountry.lstcountry.selectedindex].value.substring(0,1).toUpperCase());
Hope this helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jan 18th, 2001, 07:27 AM
#3
Thread Starter
Hyperactive Member
Hi Ian,
I get this error -
error 'document.frmcountry.lstcountry.options[...].value' is not an object.
Any ideas?? Does this code not try and retrieve the INDEX of my dropdown instead of the value/text??
T.
-
Jan 18th, 2001, 08:08 AM
#4
Fanatic Member
what the code does is in two stages
the part inside the [] gets the index of the selected option where the outside part get's the value of the selected option. there shouldn't be anything wrong with that if everything in you code is the same (including case)
try it first without ant of the substring at the end and see it it works
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jan 18th, 2001, 09:13 AM
#5
Thread Starter
Hyperactive Member
Flipping hell....
You're right it DOES work, but...
selectedindex should have a CAPITAL "I" - selectedIndex!!
I never knew that Jscript is so "touchy"!!!!
Thanks for the help Ian,
T
-
Jan 18th, 2001, 09:19 AM
#6
Fanatic Member
Sorry mate that was my fault. I forgot to put it in myself.
unfortunatley javascript is case sensative. you could be looking at a piece of code for eon's trying to work out why it isn't working and all it is is a capital letter missing
aaggghhh
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jan 19th, 2001, 08:35 AM
#7
Code:
javascript:window.resizeto(640,480);
And watch it not work!!!!
Took me ages to realise that it should have been
Code:
javascript:window.resizeTo(640,480);
-
Jan 19th, 2001, 08:54 AM
#8
Fanatic Member
That's one of the reason's why I carry interdev around with me all the time as it lays out the functions like vb does.
People say to me that real developers only use text editor's but I know what most things do and if it makes me more preductive then I don't see the peoblem.
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
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
|