Log in

View Full Version : getting values from ajax



hemi
09-17-2009, 06:54 AM
iam getting values from ajax how to store them in variables according to my code
_____________________________________________________________

<table align=center width=300 border=1> <tr> <td width=125 >Weight of <br>Empty Bottle</td>


<td align=center width=50><font size=3>[W</font><font size=1>0</font>]</td>



<td align=center>[g]</td><td><input name=one type=text size="10" value='' id='a'></td>
<tr> <td > Bottle + Dry <br>Powder</td>
<td align=center width=50><font size=3>[W</font><font size=1>1</font>]</td>

<td align=center>[g]</td><td><input name=one type=text size=10 value='' id='b'></td></tr>

<tr> <td >Specific Gravity of Liquid</td>
<td align=center width=50><font size=3>[P</font><font size=1>1</font>]</td>
<td align=center>[g/cm3]</td>
<td ><input name=one2 type=text size="10" value='' id='c'></td>
</tr>
</table>
</td>
<td width=50 >

</td>
<td>
<table align=center width=300 border=1> <tr> <td width=125 >Weight of <br>Empty Bottle</td>
<td align=center width=50><font size=3>[W</font><font size=1>2</font>]</td>
<td align=center>[g]</td><td><input name=one type=text size="10" value='' id='d'></td>
<tr> <td > Bottle + Dry <br>Powder</td>
<td align=center width=50><font size=3>[W</font><font size=1>3</font>]</td>
<td align=center>[g]</td><td><input name=one type=text size=10
value='' id="user" onblur='getContent("GET","scheduleexist.php?a="+document.getElementById("a").value+"&b="+document.getElementById("b").value+"&c="+document.getElementById("c").value+"& d="+document.getElementById("d").value+"&user="+document.getElementById("user").value,"r");'></td></tr>
<tr> <td >Specific Gravity of Liquid</td>
<td align=center width=50><font size=3>[P</font><font size=1>s</font>]</td>

echo"<td align=center>[g/cm3]</td> <td id=r> </td>
-----

____________________________________________________________
i want that to be stored in a php variable can i store it.
One more thing there r no submit button in this page values are generated dynamically.

JShor
09-17-2009, 06:45 PM
But you need to post code for scheduleexist.php. Does it even exist or need to be written from scratch? Also, how are you storing this data?

hemi
09-18-2009, 04:56 AM
<?php

include("not.php");
include("db.php");
//echo"sss $_REQUEST[a] <br>";

$w0=$_REQUEST["a"];
$w1=$_REQUEST["b"];
$w2=$_REQUEST["d"];
$w3=$_REQUEST['user'];
$p1=$_REQUEST["c"];
//echo"sss $w0 <br>";
// echo"sss $w1<br>";
// echo"sss $w2<br>";
// echo"sss $w3 <br>";
//echo"sss $p1 <br>";
$gg=$w1-$w0;

if($gg==0 || $gg=="")
{

echo"<center>null</center>";

}

else
{

$p2= (($gg)/(($w3-$w0)-($w2-$w1)))*$p1;


$re=ceil($p2);
echo"<h4><br><center>$re</center></h4> <br>";

//echo"INSERT INTO cement(ps,w0,w1,p1,w2,w3)VALUES('$re','$w0','$w1','$p1','$w2','$w3') orderby id desc"
$re=mysql_query("INSERT INTO cement(ps,w0,w1,p1,w2,w3)VALUES('$re','$w0','$w1','$p1','$w2','$w3')");

}





exit();


?>

JShor
09-18-2009, 10:53 PM
What is the script for getContent(); ? If I post one version of the code, it'll be different from your javascript.