javascript - SESSION returns old value when echoed in php -


<script language="javascript">             function emergency()             {                 if(document.getelementbyid('emer').checked == true)                 {                     <?php $_session['total2']= $_session['total1'] + 50; ?>                     document.getelementbyid('emr').innerhtml = "<b>payable amount: </b>" + <?php echo  $_session['total2']; ?>;                 }                 if(document.getelementbyid('emer').checked == false)                 {                     <?php $_session['total2']= $_session['total2'] - 50; ?>                     document.getelementbyid('emr').innerhtml = "<b>payable amount: </b>" + <?php echo  $_session['total2']; ?>;                 }             }             </script> 

here adding $_session['total1']+50 , put value in new session session['total2']. problem , when echo new $_session['total2'] out side script,ie, in page like

<?php echo $_session['total2'];?> 

it returns value of $_session['total1']).

are calling javascript function change value of php session variable?.. not possible because, php server side language , javascript client side php code gets executed when page loaded..

so if want on javascript function call,, need use ajax...


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -