Click to See Complete Forum and Search --> : Couple of very general questions


betheball
04-21-2005, 05:05 PM
Is there a difference between:

if(document.formname.checkboxname.checked==true){
alert("hello world")

and

if(document.formname.checkboxname.checked){
alert("hello world")

Second, in ASP, one can open a script with simply, "<%" and close with "%>"

Is there a similar shortcut for javascript as opposed to:

<script type="text/javascript" language="javascript"></script>

Just curious

David Harrison
04-21-2005, 05:24 PM
If the checkbox is checked then:if(document.formname.checkboxname.checked==true)would be the same as:if(true==true)Which is of course, true. If the checkbox is not checked the if statement would be the same as:if(false==true)Which is of course false. Therefore a shorter way of writing the if statement is simply:if(document.formname.checkboxname.checked)So yes, they're the same.

No, there is no shorter way of opening/closing script tags, although the language attribute is depreciated now, so the correct way to open and close script tags is like this:<script type="text/javascript"><!--

// Your code here.

//--></script>

betheball
04-21-2005, 05:29 PM
Thanks, David.

David Harrison
04-21-2005, 05:30 PM
Happy to help. :)