www.webdeveloper.com
Results 1 to 6 of 6

Thread: problem using selectedIndex

  1. #1
    Join Date
    Nov 2004
    Posts
    14

    problem using selectedIndex

    Hi all,

    I am trying to use javascript to force my select list to default to option 10.
    It seems to work fine in IE , but not Firefox. Firebug says "s has no properties"

    Any ideas? I'm sure its something simple. Here is the code:

    function getIndex()
    {
    var x=document.getElementById("F046pcode3")
    x.selectedIndex=10
    }

    Thanks

    Stu

  2. #2
    Join Date
    Jul 2005
    Location
    Tangerang, Indonesia
    Posts
    171
    x.options[10].selected=true

  3. #3
    Join Date
    Nov 2007
    Posts
    3
    my answer is same like yearbass brother...
    that good answer my brother.... i agree with you.

  4. #4
    Join Date
    Feb 2006
    Posts
    2,927
    I have to agree with firefox- your code doesn't have any s.

  5. #5
    Join Date
    Nov 2004
    Posts
    14
    sorry for the typo - should read "x has no properties"

    anyway's

    I tried the code yearbass suggested and FF didnt like that either:

    function getIndex()
    {
    var x=document.getElementById("F046pcode3")
    x.options[10].selected=true
    }

  6. #6
    Join Date
    Nov 2004
    Posts
    14
    solved - I used:

    function getIndex()
    {
    document.forms[0].F046pcode3.options[10].selected= true;
    }

    thanks for the help guys

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles