<script language="javascript"> function changeRanking(a,b) { var newA = 100; var newB = 200; } </script> I have this javascript function, It is working fine. This function execute on "onChange" event of a text field. I want to use "newA" and "newB" value in my php code after that <script> block. How can i do that. Plz help me
That is not possible. Client side values you can't use in server side scripts... You can just print them out using getElementByID Method..
They would have to be posted or sent via the URL - AJAX would probably be the best solution for this Brew
You can also pass values via GET using dummy images. document.getElementById('dummy').src = 'script.php?foo='+ bar; Code (javascript): But if you actually need a response value from the script, your only option is AJAX.
If you use a form and hidden fields inside the form to store these values on client side, then the contend will be available by posting on server side. Example: Javascript should say: document.getElementById('newA').value = 150; HTML should say: <MENU action = "POST" ...> <INPUT TYPE='HIDDEN' ID="newA" ...> <INPUT TYPE='SUBMIT' ... > </MENU> PHP should be able to retrieve your values simply by using the variable $newA alert("value on server side: ".$newA);