In the following simplified code, different version of javascript function A is used depending on something is true or false in the php program?? Is this valid? <head> <script language="javascript"><!-- <?php if (something true) { ?> function A() { document.write ("hello"); } <?php } else ?> function A() { document.write("bye"); } <?php } ?> //--></script> </head> <body> <script language="javascript"> something = true; .... onclick ="function A()" </script> </body>
Thanks a lot for the reply. One more question. Are we treating the php code inside javascript as comment so we should comment it out??