Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript question

Options
  • 26-01-2005 11:53am
    #1
    Registered Users Posts: 7,468 ✭✭✭


    Posted this on webmaster also:

    How do I set the selectedIndex for a SELECT object through javascript? :confused:


Comments

  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    var PopupMenu = eval( 'document.FormName.SelectItemName' );
    var index = PopupMenu.selectedIndex;

    I don't know if the 'selectedIndex' member is writeable, I've only ever read the value.
    I've only ever set the selected index via popup_menu function in perl's CGI module.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Just off the top of my head, can't you do something like this?
    document.formName.selectField[n].selected = true;
    

    Where 'n' is the index of the value you want to select.


  • Moderators, Politics Moderators Posts: 39,765 Mod ✭✭✭✭Seth Brundle




Advertisement