How to encrypt JavaScript code?

Php echo or print textarea doesn't work with this javascript code?

  • Ok I am not understanding this at all. It works when it is in html formate, but when I echo or print it in php it doesn't work. Here is the code modified a bit for security reasons. Can you tell me what is wrong with the coding or why its not working. Here is the javascript and the divs. <script language="javascript"> var showThis = function(caller){ switch(caller){ case "test1": document.getElementById("text").innerHTM… = "This should be echoing out, but doesn't"; break; case "test2": document.getElementById("text").innerHTM… = "What ever else"; break; default: break; } } </script> <div class="slide" style="width:100%;background-color:#CCC"… <div id="text"> Here is suppose to echo what ever I put in the javascript </div> </div> This php code is in if else statement, but it is echoed out. To save some time and effort I will just echo out the textarea within the php. <?php echo'<textarea id="table1" name="table1" style="width:60%" rows="1" onclick="showThis("test1");return false;"></textarea>'; ?> Here is the textarea in html form that works <textarea id="table1" name="table1" style="width:60%" rows="1" onclick="showThis('test1');return false;"></textarea> So if you can tell me why this is working though with the normal html, but not working with php code echoing or printing it out. Or maybe its the javascript coding or the div I would appreciate it very much.

  • Answer:

    onclick="showThis("test1");return false;" You have nested double quotes there. You need to use double outer, single inner, or single inner, double outer quotes. Then you have to make it work with the single quotes for the echo.

bestcraz... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.