vurentjie Posted May 7, 2008 Share Posted May 7, 2008 hi, i am currently developing a member/user's section of a site, a lot of the functionality that i use for speeding up processes involves passing php vars to javascript and vice-versa (although sending javascript back to php is slightly different oweing to the client/server side order of operations); one of the measures i have had to take is making the site work without javascripting as well, which means checking if javascript is enabled or not and then running the relevant php option. at the moment i what i do is this, i run a javascript onload function that changes the value of a hidden input field that i use where neccessary; then i do a check with php to see whether the value has been changed or not, and thus establish whether javascript is enabled or not; the reason that i am doing this is that i realized it is the only way I could get a javascript variable value into php - while it is relatively simple to pass php to javascript; doing something like the following <?php $var = "<script language='javascript'> document.writeln(\"hello\"); </script>"; echo $var; this will output "hello" echo strlen($var); but this will output "69" -guess why? and not the supposed "5" ?> this would've been the ideal way to build a javascript enabled check, but unfortunately i could not get any proper feedback, and is where i learnt a bit more about client/server side order of operations; i was just wandering if there has ever been any strange hacks to get this working, more a curiosity question than anything else, later vurentjie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.