Results 1 to 3 of 3

Thread: why isn't this simple script working properly?

  1. #1
    Join Date
    May 2007
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default why isn't this simple script working properly?

    so in the code below, if the user is to select the first option (with a value of "xxx") it still opens a new window. why? i want it to only open a window when the value of whichURL is something other than "xxx". i've tried using null, taking away the value of the first option, changing window.open to call a separate function, and a few other things. how can i get my desired results?

    <select name="tempGen" size="1" onChange="generate(this.form.tempGen.options)">
    <option value="xxx">•••General•••</option>
    <option value="templates/General1.html">General One</option>

    function generate(whichURL) {
    if(whichURL != "xxx") {
    window.open(whichURL[whichURL.selectedIndex].value,'POPPER','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable= no,width=200,height=200');
    }
    }

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try this instead:

    Code:
    function generate(whichURL) {
     if(whichURL[whichURL.selectedIndex].value != "xxx") {
    window.open(whichURL[whichURL.selectedIndex].value,'POPPER','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable= no,width=200,height=200');
     }
    }
    Not sure if it will work or not, but hope this helps nonetheless.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <select name="tempGen" onchange="generate(this.options[this.selectedIndex]);">
     <option value="">•••General•••</option>
     <option value="templates/General1.html">General One</option>
    Code:
    function generate(u) {
      if(u) open(
        u,
        'POPPER',
        ['toolbar=no',
          'location=no',
          'directories=no',
          'status=no',
          'menubar=no',
          'scrollbars=no',
          'resizable= no',
          'width=200',
          'height=200'
        ].join(','));
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •