Deaf Topics - Computer Programming Tutorials - Article directory - Property in Bulgaria - Watch Anime

PDA

View Full Version : Javascript variable into php variable without updating page?


colin008
Jun 14th 2007, 3:55 pm
<SCRIPT LANGUAGE="JavaScript">

function CalculateSum(Atext, Btext, form)
{
var var1
var A = parseFloat(Atext);
var B = parseFloat(Btext);
var C
form.Answer.value = A - B;
form.month.value = Math.round(form.Answer.value / 10 *100)/100;
C = form.month.value;
location.href="?var1="+C;
}
// end of JavaScript functions -->
</SCRIPT>
<FORM NAME="Calculator" METHOD="post">
<P>Total Price: <INPUT TYPE=TEXT NAME="input_A" SIZE=10 value=600></P>
<P>Deposit: <INPUT TYPE=TEXT NAME="input_B" SIZE=10></P>
<P>Finance Balance: <INPUT READONLY TYPE=TEXT NAME="Answer" SIZE=12></P>
<P>Monthly Payment: <INPUT READONLY TYPE=TEXT NAME="month" SIZE=12></P>
<P><INPUT TYPE="button" VALUE="Recalculate Payment" name="AddButton" onClick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form)"></P>
</FORM>
<? echo $_GET['var1']; ?>

This works well to get a Javascript variable in to a php variable, however is there another way to do it with out refreshing the page ?

gibex
Jun 15th 2007, 2:36 pm
use ajax to make send a variable to php script without refresh.

colin008
Jun 16th 2007, 2:40 am
Yes i have been reading up on Ajax, i think i will have to give it a go.

123GoToAndPlay
Aug 9th 2007, 4:01 am
@colin008, how did you fixs this???

i am also in need to get a js variable echoed without refresh