Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with some Js for a Select Multiple

    Hi

    Trying to do some javascript this re/dis enables a button depending on what is selected in a multiple select box. I know selectedIndex only retusn the first value that is selected which is fine, but this keeps giving me a JS error.

    This first click, gives an error but the next click it pops up an alert.

    This seems like so broken.. if i mouseclick and hold and get a couple items it sometimes gives the result of the last selectionion of the box.

    Whats up with this?

    Thanks

    <select size="8" id="availableOptions" name="availableOptions" multiple style="width:150px" onclick="alert(this.options[this.selectedIndex].value)">
    <option value="blah">more stuff</option>
    </select>
    Last edited by rishid; 05-05-2006 at 03:17 PM.

  • #2
    Regular Coder Nischumacher's Avatar
    Join Date
    Oct 2005
    Location
    Bombay, India
    Posts
    196
    Thanks
    0
    Thanked 2 Times in 2 Posts
    when first time the option is clicked... nothing is already selected... hence the error...
    you will also notice that it alert's the previously selected option then on...

    just use the onchange event insted of the onclick event...
    that should be it...
    - NS 666
    .net DEVILoper

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    haha thanks just found that last onclick bug.

    brilliant, thanks a bunch.


  •  

    Posting Permissions

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