求用js写的代码,当dropdownlist选中一项时出现相应的图片

解决方案 »

  1.   

    <form runat="server">
    <img src="" id="img" width="100" height="100" />
        <asp:DropDownList ID="DropDownList1" runat="server" onchange="javascript:document.getElementById('img').src=this.value">
        <asp:ListItem Value="http://avatar.profile.csdn.net/C/6/3/2_cykjliqian.jpg">11111111111</asp:ListItem>
        <asp:ListItem Value="http://avatar.profile.csdn.net/6/E/A/2_confidenceyu.jpg">22222222222</asp:ListItem>
        <asp:ListItem Value="http://avatar.profile.csdn.net/C/9/4/2_net_lover.jpg">33333333333</asp:ListItem>
        </asp:DropDownList>
        </form>
      

  2.   

    dropdownlist就是select
    Page_Load里面
    dropdownlist1.Attributes.Add("onchange","document.getElementById('pc').src=this.value");例如
    <img id=pc>
    <select onchange="document.getElementById('pc').src=this.value">
    <option value="http://xxx.jpg">