<script type="text/javascript">
function CalculateTotal(){
var p=document.percent.govt_share_capital.value;
var k=document.percent.total_paid.value;
var total=(p/k);
var gtotal=total*100;
//var lll=<?php //echo $gtotal; ?>;
//alert(lll);
}
</script>
<form id="percent" name="percent">
<table>
<tr>
<td>Government share capital out of total paid up share capital</td>
<td><input type="text" name="govt_share_capital" id="govt_share_capital" /></td>
<td>Total Paid up share capital</td>
<td><input type="text" name="total_paid" id="total_paid" /></td>
<td>Percentage of Government share capital to total paid up share capital</td>
<td>
<input type="text" name="gtotal" id="gtotal" value="<?php echo $lll; ?>" onclick="javascript:CalculateTotal();"/>
</td>
</tr>
<?php $total = "<script language=javascript>document.write(gtotal);</script>";
echo $total; ?>
</table>
</form>
Hi,
can anyone please help me for solve this query. I want the function should take input from the 2 fields i.e.govt_share_capital &total_paid and show the percentage in the "gtotal" field on click without page refresh that too in the same page without submitting the form.
thnks.... please help me!!!
passing javascript variable value to php without page refres
Moderator: General Moderators
Re: passing javascript variable value to php without page re
Hi,u need not pass javascript variable to php.
Try this
After this cahnge the Html code as
It is not the complete solution,but hope that you got the idea of solving the problem.
Try this
Code: Select all
var gtotal=total*100;
document.getElementById("gtotal").value=gtotal;
Code: Select all
<input type="text" name="total_paid" id="total_paid" onchange="CalculateTotal()" />
Solved: passing javascript variable value to php without pag
thanks
ya this code helps me. it works correctly........................
ya this code helps me. it works correctly........................
Last edited by lina531 on Mon Feb 06, 2012 5:13 am, edited 1 time in total.
Re: passing javascript variable value to php without page re
ok..If your problem is solved,pls change the heading as solved..Good Luck