Results 1 to 3 of 3

Thread: [RESOLVED] Dropdownlist with both onselectedindexchanged and onchange possible?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Posts
    323

    Resolved [RESOLVED] Dropdownlist with both onselectedindexchanged and onchange possible?

    Hi everyone,

    I have a dropdownlist that looks like this:

    <aspropDownList
    ID="ddlDate"
    runat="server"
    Height="25px"
    Width="200px"
    AutoPostBack="true"
    OnSelectedIndexChanged="ddlDate_SelectedIndexChanged"

    >
    </aspropDownList>

    What I want to be able to do is when the user chooses the date, I want to fire this javascript:

    function date_onchange()
    {
    divstatus.innerHTML = "<font color = red>Please wait...";
    }

    so that the user sees a "Please Wait ..." message while the data is being gathered. But when I modify the dropdownlist like this:

    <aspropDownList
    ID="ddlDate"
    runat="server"
    Height="25px"
    Width="200px"
    AutoPostBack="true"
    OnSelectedIndexChanged="ddlDate_SelectedIndexChanged"
    onchange="return date_onchange()"
    >
    </aspropDownList>

    The "Please Wait..." message appears but the ddlDate_SelectedIndexChanged routine doesn't trigger. Is there a way/better way to do this?

    Thanks!
    J

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Posts
    323

    Re: Dropdownlist with both onselectedindexchanged and onchange possible?

    Got it to work: Here's how

    <aspropDownList
    ID="ddlDate"
    onchange="date_onchange(); return true"
    runat="server"
    Height="25px"
    Width="200px"
    OnSelectedIndexChanged="ddlDate_SelectedIndexChanged"
    >
    </aspropDownList>

    function date_onchange()
    {
    divstatus.innerHTML = "<font color = red>Please wait...";
    <&#37;= ClientScript.GetPostBackEventReference(ddlDate, string.Empty) %>;
    }

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Dropdownlist with both onselectedindexchanged and onchange possible?

    Hey ediguy,

    When you are posting code into the forum, can you remember to surround it in CODE tags (you can find it in the toolbar for entering a post), not only does it make your code easier to read, but it will also stops those smilies appearing all over your code

    Gary

Posting Permissions

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



Click Here to Expand Forum to Full Width