Thursday, November 15, 2012

javascript – Toggle disable with if statement

So I am having trouble with this disable stuff. I am trying to toddle a disable with an IF statement and radio buttons. I have tried with out an if with no success. Please help if you can! My code is as follows.



<html>
<h1>Convert Temperature</h1>
<body>
<input id=\"example\" type=\"radio\" onClick=\"toggle(\'example\', \'disableMe\')\" name=\"Radio\" value=\"Radio\">
From Fahrenheit to Celsius </br>
<input id=\"example\" type=\"radio\" onClick=\"toggle(\'example\', \'disableMe\')\" name=\"Radio\" value=\"Radio\"> From Celsius to Fahrenheit
</br>
</br>
</br>
<form name=\"converter\">
Celsius: <input id=\"disableMe\" type=\"text\" name=\"celsius\" onChange=\"CelsiusConverter()\"><br />
Fahrenheit: <input id=\"disableMe\" type=\"text\" name=\"fahrenheit\" onChange=\"FahrenheitConverter()\"><br />
<input type=\"button\" value=\"Convert!\" />
</form>
</body>
<script language=\"JavaScript\">
<!--
function CelsiusConverter(){
document.converter.fahrenheit.value = (document.converter.celsius.value * 9 / 5) + 32
}
function FahrenheitConverter(){
document.converter.celsius.value = (document.converter.fahrenheit.value - 32) * 5 / 9
}
//-->
function toggle(radioID, toggleID) {
var radio = document.getElementById(radioID);
var toggle = document.getElementById(toggleID);
updateToggle = radio.checked ? toggle.disabled=true : toggle.disabled=false;

if (radioID = checked)
{
toggle.disable=true;
}
}
</script>
</html>


I know that the IF i have in there doesn\’t look right and something need to be fix but i don\’t know how!






Rating: 2 out of 5 based on 3 ratings



The post javascript – Toggle disable with if statement appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-toggle-disable-with-if-statement.html

No comments:

Post a Comment