RadioButton 切換選項時,同時變更額外想要變更的圖片
VB.Net
<script language="javascript">
function changeRadioImg(radioBox) {
var RB1 = document.getElementById('<%= rbList.ClientID %>');
var radio = RB1.getElementsByTagName("input");
var image = document.getElementById('Img');
for (var i = 0; i < radio.length; i++)
{
if (radio[i].checked)
{
image.src = "";
}
}
}
</script>
<img id="Img" alt="Img"/>
<div class="abc" style="WIDTH: 770px;HEIGHT: 100px;overflow-x:scroll;text-align:center;vertical-align :middle;border-style:outset; border-width:1px">
<asp:RadioButtonList ID="rbList" runat="server" DataTextField="img" DataValueField="id"
RepeatDirection="Horizontal" TextAlign="Left" DataTextFormatString="<img src='{0}/><br>"> </asp:RadioButtonList>
</div>
ClientScript.RegisterStartupScript(Me.GetType(), "changeRadioImg", "<script type='text/javascript'>changeRadioImg(document.getElementById('" + rbList.ClientID + "'));</script>")
0 意見: