July 25th, 2002, 10:34 AM
|
#1 (permalink)
| | Member
Join Date: Dec 2001
Posts: 68
| commenting out a block of code?
I know that <!-- some html code -->
will comment out that line of code, but what if I want to comment out a large block of code? Do i have to do that at beggining and end of each line? ugh. |
| |
July 25th, 2002, 10:37 AM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Sweden
Posts: 1,708
|
no. just do it at the beginning and the end of the code you want blocked out.  |
| |
July 25th, 2002, 10:49 AM
|
#3 (permalink)
| | Member
Join Date: Dec 2001
Posts: 68
|
Hmm I tried that and it didnt work. Is it something different for javascript? |
| |
July 25th, 2002, 11:09 AM
|
#4 (permalink)
| | Ultimate Member
Join Date: Jun 2002 Location: Iowa
Posts: 2,879
| Code:
<!--
<br>
<font color="#ffffff">
<u>This is commented out</u>
</font>
--> Make sure there are no other -->
before your ending --. |
| |
July 25th, 2002, 11:17 AM
|
#5 (permalink)
| | Ultimate Member
Join Date: Jun 2002 Location: Iowa
Posts: 2,879
|
For JavaScript
Original Code Code: <script type="text/javascript">
<!-- // Array ofmonth Names
var monthNames = new Array( "January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
thisYear = now.getYear();
if(thisYear < 1900) {thisYear += 1900}; // corrections if Y2K display problem
document.write(monthNames[now.getMonth()] + " " + now.getDate() + ", " + thisYear) ;
// -->
</script>
Code Commented out below----------- Code: <!-- // Array ofmonth Names
var monthNames = new Array( "January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
thisYear = now.getYear();
if(thisYear < 1900) {thisYear += 1900}; // corrections if Y2K display problem
document.write(monthNames[now.getMonth()] + " " + now.getDate() + ", " + thisYear) ;
// --> just remove the Script tags..... that should solve your problem
HTH's |
| |
July 25th, 2002, 07:35 PM
|
#6 (permalink)
| | Junior Member
Join Date: Apr 2002
Posts: 29
|
Or, you can do this: Code: <script type="text/javascript">
<!--
/*var monthNames = new Array( "January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
thisYear = now.getYear();
if(thisYear < 1900) {thisYear += 1900}; // corrections if Y2K display problem
document.write(monthNames[now.getMonth()] + " " + now.getDate() + ", " + thisYear) ;*/
// -->
</script> // is only for one line, /*...*/ can be used for more than one line  |
| |
July 25th, 2002, 09:58 PM
|
#7 (permalink)
| | Ultimate Member
Join Date: Jun 2002 Location: Iowa
Posts: 2,879
|
Um........ that was originally one line of code........ broke down to display........
I think he was trying to figure out how to comment out a block of code.......... so it didn't work............ but wasn't totally erased........ your way would still run the javascript..... |
| |
July 26th, 2002, 12:31 AM
|
#8 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Alberta, Canada
Posts: 563
|
Wynd is right actually... in javascript you can comment one line of code with // or you can comment a block/section/line of code by enclosing it in /* ... */
as in the following (red will not run, green will run)
(one line) /* ...some code... */
or
(one line) // ...some code...
(multiple lines) /* ...some code...
...some more code...
...some more code... */
or even (section in one line, not really recommended tho!!) ...some code /* ...some commented out code... */ ...some more code here too...
I could be missing something, but I really can't see that being one line of code anyways (not to say your wrong crouse) or if it was, imo, poor coding practice...  but even if it was one line, it still looked to be commented out properly...
anyways, cheers!  |
| |
July 26th, 2002, 12:50 AM
|
#9 (permalink)
| | Ultimate Member
Join Date: Jun 2002 Location: Iowa
Posts: 2,879
|
I stand corrected
I'm not a javascript guru..... I looked.... you guys are right ... that would do it also... |
| |
July 26th, 2002, 10:38 AM
|
#10 (permalink)
| | Member
Join Date: Dec 2001
Posts: 68
|
Thanks gang, that did it! Ok who wants to launch commentout.com that lists how to comment out for all the languages?  |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |