SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not able to select slected value of a dropdown list with javascript

    Hi all

    I have made a server side dropdown list being populated at the load of the page , I want to select the selected value ,on the client side using Javascript,
    I am not able to select the selected value any help plz.I am using asp.net

    following is the code:
    <div id="Temp4_Div_Wish" runat="server" style="visibility:hidden">
    <asp:'DropDownList ID="dd_size" runat="server" >

    </asp:'DropDownList>
    </div>

    <input type="button" value="wish" onclick="will()" />

    <script language"javascript">

    function will()
    {
    //document.getElementById('<%=dd_size.ClientID%>').style.visibility="visible";
    document.getElementById('<%=Temp4_Div_Wish.ClientID%>').style.visibility="visible";
    alert(document.getElementById('<%=dd_size.ClientID%>').options[this.selectedIndex].value);

    }

    </script>

    ' used to not to show smiley

  2. #2
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the problem is
    alert(document.getElementById('<%=dd_size.ClientID%>').options[this.selectedIndex].value);

    you should change with
    alert(document.getElementById('<%=dd_size.ClientID%>').options[document.getElementById('<%=dd_size.ClientID%>').selectedIndex].value);

  3. #3
    SitePoint Enthusiast navtej's Avatar
    Join Date
    May 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks


Bookmarks

Posting Permissions

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