In comp.lang.javascript message <17ff2a9f-cae4-419a-84bb-060d79912402@k3
0g2000hse.googlegroups.com>, Mon, 21 Jul 2008 23:42:19, smartwebcoder
<smartwebcoder@gmail.composted:
Quote:
>
><script language="javascript" type="text/javascript">
^^^^^^^^^^^^^^^^^^^^^ <- superfluous and deprecated
Quote:
var flag=false;
function Add(chkid)
{
>
if(flag==false)
{
document.getElementById(chkid).checked=true;
flag=true;
}
else
{
document.getElementById(chkid).checked=false;
flag=false;
}
>
}
</script>
>
You are posting with a false identity : no-one smart would consider that
code to be worth posting. Remember - the inadequate boast of their
prowess, the competent just display it.
There is no need to use == false since JavaScript has a NOT
operator, '!'; and if you don't like that you can reverse the then and
else parts.
But there is no need to use the if at all;
{ document.getElementById(chkid).checked = flag = ! flag }
should be equivalent to the body of your function Add .
Firefox 3.0.1 is out.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)