14,932,486 members
1.00/5 (1 vote)
See more:
nilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnil
Posted
Updated 21-Nov-13 18:24pm
v4

What will be your logic? Suppose user enters 349, then how will you split?
Er Daljeet Singh 20-Nov-13 1:17am

Its not clear what you want to achieve.so elaborate your question
Arun-23 20-Nov-13 1:41am

The value for 2nd 3rd and 4th box is fixed as 100 50 50 if the user enters 300 the value should split it into 100 50 50 and remaining 100 should be in balance box...

suppose if the user enters 100 it should fill the first box other box should be zero..

suppose if the user enters 50 it should fill the second box other box should be zero.. like tat i had tried the following code but it has error...
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script>
window.update = function() {
var one = document.getElementById('one'),
two = document.getElementById('two');
three = document.getElementById('three');
four = document.getElementById('four');
five = document.getElementById('five');

two.value = parseInt(one.value) - 100;

//if(two.value < 100)
// {
three.value = parseInt(two.value) - 50;
//}

//if(two.value > 100)
//{
// three.value = parseInt(two.value) - 0;
four.value = parseInt(three.value) - 50;
//}
five.value = parseInt(three.value) - 50;
}

function checknumber(txtid) {
var mynumbervalue = parseFloat((txtid).value);
if (mynumbervalue > 100) {
txtid.value = "0";
}
if (theid.value < 0) {
txtid.value = "0";
}
}
</script>
<body><br><p align="center">
Enter the amount to be paid<input id="one" type="text" önChange="update();" /><br>
Book fees<input id="two" type="text" name="txt" önchange="checknumber(this)"/> 100<br>
uniform fees<input id="three" type="text" /> 50<br>
Bus fees<input id="four" type="text" /> 50<br>
balance fees<input id="five" type="text" /> <br>

</p>
</body>
</html>

So, what is the exact problem with this code?
Er Daljeet Singh 20-Nov-13 3:04am

again we are not getting anything.
yes we understand you want to deduct 100,50,50 but from which which text box you want do deduct it.
you said if user enter 300
then
1st textbox=300
2nd textbox= minus 100
3rd textbox= minus 50
4th textbox= minus 50
5th textbox=100

but from which value we want to deduct.
suppose if i minus 100 from 300 then 200 balance now for the third texbox from which value if want to deduct whether from 300 ,200 or the balance.

Clearly ask what logic you want to implement.
Er Daljeet Singh 20-Nov-13 3:05am

here is some modification in your code
<html>
<title></title>
<script type="text/javascript">
function updateValue() {
var one = document.getElementById('one');
var two = document.getElementById('two');
var three = document.getElementById('three');
var four = document.getElementById('four');
var five = document.getElementById('five');
two.value = parseInt(one.value) - 100;
three.value = parseInt(two.value) - 50;
four.value = parseInt(three.value) - 50;
five.value = parseInt(one.value) - (parseInt(two.value) + parseInt(three.value) + parseInt(four.value));
}
function numeralsOnly(evt) {
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode > 47 && charCode < 58) {
}
else {
if (charCode == 8) {
return true;
}
else {
return false;
}
}
}

</script>
<body>
<br>
<p align="center">
Enter the amount to be paid<input id="one" type="text" onchange="updateValue()" önkeypress="return numeralsOnly(event)" />
<br>
Book fees<input id="two" type="text" name="txt" />
100
<br>
uniform fees<input id="three" type="text" />
50
<br>
Bus fees<input id="four" type="text" />
50
<br>
balance fees<input id="five" type="text" />
<br>
</p>
</body>
</html>