当通过单选按钮选择更改隐藏输入时,运行javascript函数

时间:2014-01-11 19:03:13

标签: javascript html

选择单选按钮后,我无法运行javascript函数。我可能只是错过了一件小事或者更多。

<html>
<head>
<title>Place a title here.</title>
<meta charset="utf-8">
    <script src="js\utilities.js"></script>
    <script src="js\backgroundworker.js"></script>
</head>
<body>
<div id="master">
<form action='' method="post" id="LoginForm">
        <div style='text-align: center'>
            <div><label>Please pick a poulation size: </label></div>
            <div style="width: 33%; float:left;"><label for="small">Small<input type="radio" name="PopulationSize" id="small" value="small" onclick="document.getElementById('checked_radio').value=this.value;" /></label></div>
            <div style="width: 33%; float:left;"><label for="medium">Medium<input type="radio" name="PopulationSize" id="medium" value="medium" onclick="document.getElementById('checked_radio').value=this.value;" /></label></div>
            <div style="width: 33%; float:left;"><label for="large">Large<input type="radio" name="PopulationSize" id="large" value="large" onclick="document.getElementById('checked_radio').value=this.value;" /></label></div>
            <input type="hidden" id="checked_radio" name="checked_radio" value="" />
        </div>  
</form>
</body>
</html>

我有一个标准的javascript实用程序来发现和简写功能。

function Bobsalert(){
// get the value of the hidden text
var checked_radio = U.$("checked_radio");
//call alert popup
window.alert("change detected value is: "  + checked_radio);
}

window.onload = function (){

if(U.$("checked_radio") !== null) {
U.addEvent(U.$('checked_radio'),'onchange', Bobsalert);
}
}

提前感谢您对此提供任何帮助。我似乎被卡住了。

0 个答案:

没有答案