[英]How do I turn this radio button javascript to a link activated javascript
Just as the title says, I have this javascript that is currently being controlled by radio buttons but I want it changed to be controlled by a hyperlink 就像标题说的那样,我有这个JavaScript,该JavaScript当前由单选按钮控制,但我希望将其更改为由超链接控制
Javascript: Javascript:
function Init()
{
document.role_form.reset();
document.host_form.reset();
document.guest_form.reset();
//MBR Code: Use querystring to initialize the form
var sRole = GetQueryString()["role"];
if (sRole) {
SelectRole(sRole)
if (sRole != '')
{
document.role_form.role[0].checked = sRole.toLowerCase() == 'host';
document.role_form.role[1].checked = sRole.toLowerCase() == 'guest';
}
}
current HTML form (Radio buttons): 当前的HTML表单(单选按钮):
<form name="role_form">
<p align="center" style="FONT-SIZE:12px; COLOR:#000000; TEXT-ALIGN:center">
<input name="role" id="role" type="radio" value="host" onClick="SelectRole('host')">
<span class="blackbodymain ">Host </span>
<input name="role" id="role" type="radio" value="guest" onClick="SelectRole('guest')">
<span class="blackbodymain ">Participant </span></p>
</form>
And how I want to control it: 以及我要如何控制它:
<ul id="loginmenu">
<li class="active"><a href="#host" onClick="SelectRole('host')">Host</a></li>
<li><a href="#participant" onClick="SelectRole('guest')">Participant</a></li>
</ul>
Perhaps the problem has something to do with what is returned from selectRole. 也许问题与selectRole返回的内容有关。 I don't know because I can't see it, but link wont happen if the function returns false (or something evaluated to false)
我不知道,因为我看不到它,但是如果函数返回false(或评估为false的东西),则不会发生链接
<li class="active"><a href="#host" onclick=selectAndGo('host')">Host</a></li>
<li><a href="#guest' onclick='selectAndGo('guest')">Participant</a></li>
And in the javascript 并在javascript中
function selectAndGo(arg)
{
selectRole(arg);
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.