I have a page which has already done some ajax calls to php and has set some session variables. within my main page i need to now check these session varibles.. if i was to use javascript the code could be something like <input id="question" type="text" name="question" maxlength="100" value="<?php echo "" ?>" style="width:590px" onkeydown="output()" /> <script language="javascript" type="text/javascript"> function output() { <?php if ( $_SESSION ["proselected"] == "yes" ) { ?> document.speakerForm.question.readOnly=false; <?php } else { ?> document.speakerForm.question.readOnly=true; <?php } ?> } </script> Code (markup): The problem with this obviously is that the session variable is always going to be set to no because when the main page loaded the proselected session variable had not been set. So, I need a way using ajax to check the state of the proselected session variable and if it is set to yes then the textfields readonly state can be set to false.. thanks..
so the session variable is modified after the page has already loaded by another call to a PHP script? The proselected session variable's state should be saved between calls, that is the point of session variable, make sure you are making a call to session_start(), which might be why the session data is not saved. Then you could set up a script to activate when the "question" box is selected to know what the updated the variable is, the trick is finding out which event you need to call the PHP script on. Do you need help with actually writing the javascript to get the sesson variable from your PHP script?
When you do callback to page that set some session value, you call a php check() function. Depend on the value of session you output 0 or 1 (using echo function of php). At client-side you can get the return content from server after callback. The text will be "0" or "1". Alright... at this point you write javascript to set correctly the readOnly in mainpage depend on that returned text from server.