Click to See Complete Forum and Search --> : Does this code look good or not ? esp. to Charles


arash
11-05-2003, 11:08 AM
<html>
<head>
<title>Example</title>

<style type="text/css">
<!-- this part causes the boxes appear columnshape , otherwise appear in a row
label {display:block; margin:1em 0em}
input {display:block}
-->
</style>

<script type="text/javascript">
<!--
var totalBeginnigBalace=0;
var totalDeposit, totalWithdra, totalTax

Array.prototype.sum = function () {var n=0; for (var j=0; j<this.length; j++) {n += this[j]}; return n};

function depositCollections (n) {
var a = new Array();
for (var j=0; j<n; j++) {a[j] = Number(prompt(['Please enter yr deposit nr', j + 1, 'out of total deposit of', n].join(' '), ''))}
totalDeposit=a.sum();
totalBeginnigBalace = Number(frmMonthlyBalance.balanceInput.value);
return a.sum();
}

function widthdrawalCollections (n) {
var a = new Array();
for (var j=0; j<n; j++) {a[j] = Number(prompt(['Please enter yr withdrawal nr', j + 1, 'out of total withdrawal of', n].join(' '), ''))}
totalWithdra=a.sum();
totalTax = ((totalBeginnigBalace + totalDeposit-totalWithdra)* 0.01)
frmMonthlyBalance.finalBalance.value=((totalBeginnigBalace + totalDeposit-totalWithdra)+ totalTax)
return a.sum();
}
// -->
</script>
</head>
<body>

<form name="frmMonthlyBalance" action="" onsubmit="return false">
<div>
<label>Enter your beginning balance<input type="text" name="balanceInput"></tabel><br>
<label>Total Number of Deposits<input type="text" onchange="this.form.totalAmount.value = depositCollections(this.value)"> </label>
<label>Total Amount Deposited<input name="totalAmount" type="text"></label>


<label>Total Number of widthdrawal<input type="text" onchange="this.form.totalwidthdrawal.value = widthdrawalCollections(this.value)"> </label>
<label>Total Amount of withdrawaed<input name="totalwidthdrawal" type="text"></label>
<label>your total at the end of the month applied to tax 0.01=====>>>><input type="label" name="finalBalance"></label>
<button type="submit">Submit</button>

</div>
</form>
</body>
</html>:confused: :confused:

havik
11-05-2003, 01:53 PM
My quick comments would be to add a doctype and charset, then validate it. Also, I would save the style and scripts in external files and link to them. (This is for the html)

arash
11-05-2003, 10:01 PM
Hi , i 'll appreciate if you tell me some more about it .
thank you :)

havik
11-06-2003, 10:27 AM
Check out these links on css and html, as for the javascript...if it works, then it works.

list of valid DTD's (http://www.w3.org/QA/2002/04/valid-dtd-list.html)
html 4.01 specification (http://www.w3.org/TR/html4/)
html validator (http://validator.w3.org/)
css validator (http://jigsaw.w3.org/css-validator/)

A lot of members have links in their signatures to web sites promoting/tutoring/etc... the folowing: html validation, css validation, doctypes, html and xhtml specifications, etc... The links above are in Jona's signature (sorry to steal Jona, I needed some links :D)

Havik

arash
11-07-2003, 02:05 AM
I liked it but my main focus was on how the code was designning . sorry about the confusion.