...

View Full Version : Billing System through Javascript



ApniGang
05-15-2009, 12:26 PM
<table width="462" border="0" align="center">
<tr>
<td height="26" align="left"><span class="style9">No.</span></td>
<td align="left"><span class="style9">description</span></td>
<td align="left"><span class="style9">qty</span></td>
<td align="left"><span class="style9">unit</span></td>
<td align="left"><span class="style9">total</span></td>
</tr>
<tr>
<td width="57" height="26" align="left"><input type="text" size="5" name="d10" /></td>
<td width="187" align="left"><input type="text" size="25" name="d" /></td>
<td width="58" align="left"><input type="text" size="25" name="d2" /></td>
<td width="89" align="left"><input type="text" size="25" name="d3" /></td>
<td width="49" align="left"><input type="text" size="25" name="d4" /></td>
</tr>
<tr>
<td height="26" align="left"><input type="text" size="5" name="d15" /></td>
<td align="left"><input type="text" size="25" name="d" /></td>
<td align="left"><input type="text" size="25" name="d8" /></td>
<td align="left"><input type="text" size="25" name="d5" /></td>
<td align="left"><input type="text" size="25" name="d11" /></td>
</tr>
<tr>
<td height="26" align="left"><input type="text" size="5" name="d16" /></td>
<td align="left"><input type="text" size="25" name="d" /></td>
<td align="left"><input type="text" size="25" name="d9" /></td>
<td align="left"><input type="text" size="25" name="d6" /></td>
<td align="left"><input type="text" size="25" name="d12" /></td>
</tr>
<tr>
<td height="26" align="left"><input type="text" size="5" name="d17" /></td>
<td align="left"><input type="text" size="25" name="d172" /></td>
<td align="left" bgcolor="#FFFFFF"><input type="text" size="25" name="d173" /></td>
<td align="left"><input type="text" size="25" name="d7" /></td>
<td align="left"><input type="text" size="25" name="d13" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="style7">&nbsp;</td>
<td>&nbsp;</td>
<td><span class="style7">Grand Total </span></td>
<td><input type="text" size="25" name="d14" /></td>
</tr>
<tr>
<td colspan="5" align="center"><input type="submit" name="submit" value="Add Invoice" /></td>
</tr>
</table>



http://i39.tinypic.com/2m7vh90.jpg


Here i post code and img both.
i want that i only write quantity and unit. Total and Grand Total will automatic change .
please send me full code of javascript

thank you :)

Stooshie
05-15-2009, 04:15 PM
Hmm, this sounds a little bit like a homework assignment.

I'll give you a clue. You need to think about adding onchange events to some of the text boxes and write a function to handle those changes.

Even if this is not homework, I would suggest that asking "please send me full code of javascript" is not the best way to get a reply.

good luck!

Philip M
05-15-2009, 06:52 PM
You will also need to validate that the user entries for qty and unit (what is that?) are valid numbers within an acceptable range.

ApniGang
05-16-2009, 07:31 AM
<script language="javascript" type="text/javascript">

function addd() {
document.addem.input1.value= ""
document.addem.input2.value= ""
document.addem.input3.value= ""
document.addem.input4.value= ""
}

function addthem() {
//FIRST INPUT VALUE
var add1 = document.addem.input1.value
var add1 = parseFloat(add1, 10)
add1 = (isNaN(add1))?0:add1;

//SECOND INPUT VALUE
var add2 = document.addem.input2.value
var add2 = parseFloat(add2, 10)
add2 = (isNaN(add2))?0:add2;

//Third INPUT VALUE
var add3 = document.addem.input3.value
var add3 = parseFloat(add3, 10)
add3 = (isNaN(add3))?0:add3;

//Four INPUT VALUE
var add4 = document.addem.input4.value
var add4 = parseFloat(add4, 10)
add4 = (isNaN(add4))?0:add4;

//ADD THEM TOGETHER
return eval(add1) * eval(add2);

//ADD THEM TOGETHER
return eval(add3) * eval(add4);
}

function addition() { document.addem.answer.value = addthem() }
function additions() { document.addem.answer2.value = addthem() }

</script>

here is JavaScript code. the first line of qty and unit working but second link of qty and unit giving same answer of first line .
please tel me the correct code

thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum