Please help with a Javascript!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Walsh

    Please help with a Javascript!

    Hello, I am having problems with one of the java scripts on my website
    and I was hoping that maybe someone could tell me what I'm doing wrong
    and how to fix my problem.

    The problem is that I have a pull down menu in the middle of one of
    the pages of my website

    and it does not seem to be working properly on macintosh systems using
    Safari or Firefox Browsers. It works fine on Internet Explorer and
    Netscape.

    If you could please take a look at the page and the source code to see
    if you can figure out what the problem is for me, I would really
    appreciate your help. Or if you know a script that you know works in
    safari as a pull down menu, maybe you could share the code with me.

    Thank you in advance for your time and help.
    Have a great day!
    Christopher Walsh
    Pictronica Enterprises

  • Stewart Gordon

    #2
    Re: Please help with a Javascript!

    Christopher Walsh wrote:
    [color=blue]
    > Hello, I am having problems with one of the java scripts on my website
    > and I was hoping that maybe someone could tell me what I'm doing wrong[/color]

    1. Talking of "java scripts". It's JavaScript (one word).

    2. Using a vague subject line.

    3. Writing somewhat broken HTML code. http://validator.w3.org/ is your
    friend.
    [color=blue]
    > and how to fix my problem.[/color]
    <snip>

    It appears that Safari doesn't recognise the assign method. I don't see
    what the point is - assigning in the normal way works perfectly fine.

    Moreover, you can get the value of the selected item directly - no need
    to go through the index.

    This code works in Safari, IE and Mozilla:

    function openDir(form) {
    if (document.form. fieldname.selec tedIndex != 0)
    cururl = document.form.f ieldname.value;
    window.location .href = cururl;
    }
    }

    (Your alert on selecting "CHOOSE A PHOTO GALLERY" seemed pointless to
    me, so I removed it.)

    HTH

    Stewart.

    Comment

    • Stewart Gordon

      #3
      Re: Please help with a Javascript!

      Stewart Gordon wrote:

      <snip>[color=blue]
      > function openDir(form) {
      > if (document.form. fieldname.selec tedIndex != 0)
      > cururl = document.form.f ieldname.value;
      > window.location .href = cururl;
      > }
      > }[/color]

      Oops, I don't know where the open brace got lost.

      But we might as well cut out another middleman....

      function openDir(form) {
      if (document.form. fieldname.selec tedIndex != 0) {
      window.location .href = document.form.f ieldname.value;
      }
      }

      Stewart.

      Comment

      • Michael Winter

        #4
        Re: Please help with a Javascript!

        On Mon, 25 Oct 2004 17:21:03 +0100, Stewart Gordon <smjg_1998@yaho o.com>
        wrote:
        [color=blue]
        > Stewart Gordon wrote:
        >
        > <snip>[color=green]
        >> function openDir(form) {
        >> if (document.form. fieldname.selec tedIndex != 0)
        >> cururl = document.form.f ieldname.value;[/color][/color]

        [snip]
        [color=blue]
        > But we might as well cut out another middleman....[/color]

        Particularly as it was global. Always use the var keyword to declare
        variables.
        [color=blue]
        > function openDir(form) {
        > if (document.form. fieldname.selec tedIndex != 0) {
        > window.location .href = document.form.f ieldname.value;
        > }
        > }[/color]

        Perhaps you meant:

        form.fieldname

        so that the function argument is actually used. However, based on what the
        OP is trying do, this:

        <select onchange="openD ir(this);">


        function openDir(elem) {
        var i = elem.selectedIn dex;
        if(0 != i) {location = elem.options[i].value;}
        }

        By the way, fieldname is a terrible name for a form control.

        Finally, for a discussion on this navigation technique, please read
        (<URL:http://groups.google.c om/groups?threadm= da7e68e8.040917 1356.25f6eca9%4 0posting.google .com>).

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • kaeli

          #5
          Re: Please help with a Javascript!

          In article <clj8ud$a14$1@s un-cc204.lut.ac.uk >, smjg_1998@yahoo .com
          enlightened us with...[color=blue]
          >
          > Moreover, you can get the value of the selected item directly - no need
          > to go through the index.
          >
          > This code works in Safari, IE and Mozilla:
          >
          > function openDir(form) {
          > if (document.form. fieldname.selec tedIndex != 0)
          > cururl = document.form.f ieldname.value;[/color]

          I remember that there was a browser (or browsers?) that this didn't work with
          because I stopped using it and reverted to using the fully qualified value
          with the options. Perhaps Netscape 4?
          I'd love to verify that it works in IE6 (windows and Mac), Netscape 6+,
          Firefox/Mozilla, Opera, Safari, and Konqueror...any one test it in all those?
          The longhand is such a PITA...

          --
          --
          ~kaeli~
          User: The word computer professionals use when they mean
          'idiot'.



          Comment

          • Christopher Walsh

            #6
            Re: Please help with a Javascript!

            Hello everybody,
            I just wanted to take the time to thank you all for your help and
            suggestions. I'm pretty sure I got it to work now, but if you
            wouldn't mind double checking for me, the address is


            In anycase,
            Have a great day,
            Christopher Walsh
            Pictronica Enterprises


            kaeli <tiny_one@NOSPA M.comcast.net> wrote in message news:<MPG.1be6f 44f167a92698a21 6@nntp.lucent.c om>...[color=blue]
            > In article <clj8ud$a14$1@s un-cc204.lut.ac.uk >, smjg_1998@yahoo .com
            > enlightened us with...[color=green]
            > >
            > > Moreover, you can get the value of the selected item directly - no need
            > > to go through the index.
            > >
            > > This code works in Safari, IE and Mozilla:
            > >
            > > function openDir(form) {
            > > if (document.form. fieldname.selec tedIndex != 0)
            > > cururl = document.form.f ieldname.value;[/color]
            >
            > I remember that there was a browser (or browsers?) that this didn't work with
            > because I stopped using it and reverted to using the fully qualified value
            > with the options. Perhaps Netscape 4?
            > I'd love to verify that it works in IE6 (windows and Mac), Netscape 6+,
            > Firefox/Mozilla, Opera, Safari, and Konqueror...any one test it in all those?
            > The longhand is such a PITA...
            >
            > --[/color]

            Comment

            Working...