Monday 15 April 2013

Embedding javascript within php code -



Embedding javascript within php code -

i have embedded javascript within php code. necessary after checking php session variable value, , upon result, utilize js within php decide if elements shown or not. here example:

<?php if ($_session['myvar']==2) { echo '<script type="text/javascript" > document.getelementbyid("element1").style.visibility = "hidden"; document.getelementbyid("element2").style.visibility = "hidden"; </script>'; ?>

the code works perfect me. question : js executed @ webserver(since embedded within php code) , initializing page before sent client browser (and think), or php portion run @ server, , js runs @ client later??

i know in normal situations js runs @ client browser,but suspicious in case,

i'm junior programmer , help appreciated, in advance.

javascript always executed in browser of client. php code inserts javascript code block of text , browser reads code.

javascript php client-side server-side embedding

No comments:

Post a Comment