www.webdeveloper.com
Results 1 to 2 of 2

Thread: Reseting select in form

  1. #1
    Join Date
    Jan 2012
    Posts
    34

    Reseting select in form

    i have it working if i do not try a variable with it

    document.formName.selectName.selectedIndex = "0";

    when using it in a function with variables it doesnt work
    Code:
    function bob(fname,sname){
    var rsel= 'document.'+fname+'.'+sname+'.selectedIndex = ';rsel+"0";
    }

  2. #2
    Join Date
    Oct 2012
    Posts
    41
    I'de use this method instead:

    var selectObject = document.getElementById( sname );
    selectObject.selectedIndex = 0;

    where sname is the id attribute of the select tag.

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