如何解决如何创建一个Javacript函数来读取下拉列表以显示单选按钮?
我有一个带有数据的下拉列表,如果我选择某件事,它会显示小时单选按钮或薪水单选按钮,例如,如果我选择“经理”,它将显示薪水单选按钮并选中它,如果我选择“厨师”,应选中“小时”单选按钮。
<select name="ntitle">
<option selected value="0"> </option>
<%do until rsPositions.eof
strContent = rsPositions("descrip")
StrValue = rtrim(rsPositions("descrip"))
intThisId = rsPositions("id")
if ucase(rtrim(strNtitle))=ucase(strValue) then%>
<option selected value="<%=strValue%>"><%=StrContent%></option>
<%else
if not StrReadOnly then%>
<option value="<%=strValue%>"><%=StrContent%></option>
<%end if
end if
rsPositions.movenext
loop%>
</select>
单选按钮代码:
if StrNewtype="H" then%>
<input type="radio" name="newtype" value="H" checked>
<% else%>
<input type="radio" name="newtype" value="H">
<% end if%>Hourly
<% if StrNewType="S" then%>
<input type="radio" name="newtype" value="S" checked>
<% else%>
<input type="radio" name="newtype" value="S">
<% end if%>Salary(<%=StrPayCycleDes%>)
解决方法
在经典ASP脚本中检索数据时,请进行修改以适合您的需求:
function kick1()
{
var e = document.getElementById("post");
var strPost = e.value;
if (strPost=="Cook")
{
document.getElementById("TT1").checked=true;
}
if (strPost=="Manager")
{
document.getElementById('TT2').checked=true;
}
if (strPost=="")
{
document.getElementById('TT1').checked=false;
document.getElementById('TT2').checked=false;
}
}
<select onchange='javascript:kick1();' id=post>
<option value="">Please select
<option value="Manager">Manager
<option value="Cook">Cook
</select>
<br>
<input type=radio name=newtype id=TT1 value='H'>Hourly
<input type=radio name=newtype id=TT2 value='S'>Salary
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。