0
   

How to use this js code in my form.

 
 
Farzad
 
Reply Mon 14 Jul, 2014 11:03 pm
I have a form which needed for some automatic calculations.

Fields of my form are as following:

Earn Amount (It’s going to be enterd by Owner of form).

Tax Deduction (It’s a dropdown box, by selecting one value it will deduct tax from the value of Earn Amount field).

Amount Payable (The Tax Deduction must deduct tax from the value of Earn Amount and display the result value here).

Amount Paid (The value of the Amount Payable will be entered here for editing).

Amount Remain With Office (If th complete value of the Amount Payable entered to the

Amount Paid so the Amount Remain With Office is going to be(0), if we entered less than Amount Payable into Amount Paid field, so the remain value should be displayed to Amount Remain With Office field). What I want is these all should be done automatically, Cause there is a submit button for entering these information to DB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">

// get input element
var getSum = document.getElementById("earnamount");
// get select element
var getMethod = document.getElementById("taxdeduction");

// create a logic for changing selected options
getMethod.addEventListener("change", function(e)
{

document.getElementById("amountpayable").value= "some data";

document.getElementById("amountpaid").value = "some data"

document.getElementById("amountremainwithoffice").value = "some data"
});

</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Calculate</title>
</head>
<body>

<form action="#" method="post">
Earn Amount:<br />
<input type="number" id="earnamount" ><br /><br />

Tax Deduction:<br />

<select name="taxdeduction" id="taxdeduction" style="width:150px;" size="1">

<option value="0" selected="selected" disabled="disabled">Tax Deduction</option>
<option value="0.02">Two Percent (2%)</option>
<option value="0.05">Five Percent (5%)</option>

</select><br /><br />

Amount Payable:<br />
<input type="number" id="amountpayable" ><br /><br />

Amount Paid:<br />
<input type="number" id="amountpaid" ><br /><br />

Amount Remain With Office:<br />
<input type="number" id="amountremainwithoffice" ><br /><br />
<input type="submit" value="Submit To Database" />
</form>

</body>
</html>
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 590 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » How to use this js code in my form.
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/16/2024 at 09:21:29