Forum Moderators: open
Here is the javascript-
<script type="text/javascript">
function enableUs(c, b)
{
var i=0;
var m=new Array();
m=document.getElementsByName(c, b);for (i=0;i<m.length;i++)
{
alert("in loop and b is " + b)
m.item(i).disabled=b;
}
return true;
}
</script>
This is the code that calls it-
echo "<p>";
echo "<input type='radio' name='pos_button' value='$interpret' id='$interpret' onclick='return enableUs(\"lang_button\", \"false\")'/>";
echo "<label for='pos_button'><FONT face='Verdana,Helvetica' SIZE='3' COLOR='Blue'><B>Interpreter</B></FONT></label>";
echo "<p id='interpret' style='display:block; margin-left:6px'>";
foreach ($_LANGUAGE as $key => $id)
{
echo "<p>";
echo "<input type='radio' name='lang_button' value=$key id=$key disabled='true'/>";
echo "<label for='lang_button'><FONT face='Verdana,Helvetica' SIZE='3' COLOR='Blue'><B>".$id['title']."</B></FONT></label>";
}
echo "</p>";
Can anyone see what I'm missing? Please?
Thanks,
Sara
<script type="text/javascript">
function enableUs(c, b)
{
var i=0;
var m=new Array();
m=document.getElementsByName(c);for (i=0;i<m.length;i++)
{
alert("in loop b is " + b)
m.item(i).disabled=b;
}
return true;
}
</script>
false
0 (zero)
"" (empty string)
null
undefined
NaN (a special value meaning Not a Number)
All other values are truthy. Any non-empty string is truthy, including "0" (zero in quotes) and "false" (false in quotes).
So the reason "true" worked for you was because "true" is a non-empty string, so therefore will evaluate to true when coerced to a boolean value. :)