www.webdeveloper.com
Results 1 to 4 of 4

Thread: Remove the default value selected in a drop-down box

  1. #1
    Join Date
    May 2012
    Posts
    2

    Remove the default value selected in a drop-down box

    I'm trying to remove the default value selected in a drop-down box.

    The call to the function is this:
    onchange="javascript:Remove_Default_Value(this);"

    Here is the function:
    function Remove_Default_Value(DROPDOWN)
    {
    var i = DROPDOWN.options.length - 1;
    for ( i; i >= 0; i--)
    {
    DROPDOWN(i).defaultSelected = false;
    }
    }

    The error I'm getting in Firefox is:
    "DROPDOWN is not a function".

    Any ideas is greatly appreciated.

  2. #2
    Join Date
    Nov 2010
    Posts
    1,049
    Code:
    DROPDOWN[i].defaultSelected = false;

  3. #3
    Join Date
    May 2012
    Location
    India , Calicut
    Posts
    4

    Thumbs up [resolved] try this

    Quote Originally Posted by mark.ebling@gma View Post
    I'm trying to remove the default value selected in a drop-down box.

    The call to the function is this:
    onchange="javascript:Remove_Default_Value(this);"

    Here is the function:
    function Remove_Default_Value(DROPDOWN)
    {
    var i = DROPDOWN.options.length - 1;
    for ( i; i >= 0; i--)
    {
    DROPDOWN(i).defaultSelected = false;
    }
    }

    The error I'm getting in Firefox is:
    "DROPDOWN is not a function".

    Any ideas is greatly appreciated.

    Try this...

    DROPDOWN(i).selectedIndex = 0;

  4. #4
    Join Date
    May 2012
    Posts
    2

    [RESOLVED] Thanks xelawho!

    DROPDOWN[i].defaultSelected = false; worked!

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