FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Online string comment

 


Alie
Good day!
I've asked this question already in one of the topics, but I guess nobody have seen it untill now, so I start a new topic.
Ok, this is it:
Is there any javascript code, that can comment strings in files? Here is an example:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
echo "Some text";
...
?>

When I press button1 on my site, I want to string:
Code:
echo "Some text";

become commented. Code changes after pressing button1:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
//echo "Some text";
...
?>

Now, if I'll press button1 ones more - comment must be deleted and string become open for browser:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
echo "Some text";
...
?>

Thank you!
ThePolemistis
Alie wrote:
Good day!
I've asked this question already in one of the topics, but I guess nobody have seen it untill now, so I start a new topic.
Ok, this is it:
Is there any javascript code, that can comment strings in files? Here is an example:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
echo "Some text";
...
?>

When I press button1 on my site, I want to string:
Code:
echo "Some text";

become commented. Code changes after pressing button1:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
//echo "Some text";
...
?>

Now, if I'll press button1 ones more - comment must be deleted and string become open for browser:
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
echo "Some text";
...
?>

Thank you!


err... can't u just use an if condition?
like

Code:
<?php
....
   <img src='img/button1.gif'>
   echo "<P>";
    if ($showText==true){
      echo "Some text";
      $showText==false;
   } else {
      echo "//Some text";
      $showText==true;
   }
....
?>


I think that is should do what ur trying to do.
jabapyth
javascript can't effect serverside PHP. If you are displaying the php on this page of yours, then:

in the html, put
Code:
<?php
....
<img src='img/button1.gif'>
echo "<P>";
<span id="tocomment" style="visibility:hidden;position:absolute">//</span>echo "Some text";
...
?>

in javascript put
Code:
var commented=0;
function commentout(){
     if (commented){s=document.getElementById('tocomment');
        s.visibility="hidden";
        s.position="absolute"}
    else{
        s=document.getElementById('tocomment');
        s.visibility="visible";
        s.position="";
    }
}
Alie
Thanks to everyone for your help Wink
I've solved the problem at last Twisted Evil
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.