Results 1 to 8 of 8

Thread: Jscript - why does this not want to work in NS

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Angry

    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>


  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Angry

    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.

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Question 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

  6. #6
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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!

  7. #7
    Guest
    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);

  8. #8
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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
  •  



Click Here to Expand Forum to Full Width