I've made this simple script to automatically add up set numbers in hidden text boxes, but it doesn't work, and I don't know why. Could someone help me with this matter?
The script follows...
<script language="JavaScript">
function total(form)
{ form.total.value = ((form.text.value*1)+(form.button.value*1)+(form.pro.value*1)+(form.real.value*1)+(form.misc.value*1)) }
document.write("<form>");
document.write("<input type=hidden name=text value=32>");
document.write("<input type=hidden name=button value=10>");
document.write("<input type=hidden name=pro value=5>");
document.write("<input type=hidden name=real value=6>");
document.write("<input type=hidden name=misc value=4>");
document.write("<input type=button value='=' onClick=total(this.form)><input type=text name=total>");
document.write("</form>");
</script>
- Will
SitePoint Member
Here is the correct code of your script:
function Total(form){
form.total.value = (form.text.value*1)+(form.button.value*1)+(form.pro.value*1)+(form.real.value*1)+(form.misc.value*1)
}
document.write("<form>");
document.write("<input type=hidden name=text value=32>");
document.write("<input type=hidden name=button value=10>");
document.write("<input type=hidden name=pro value=5>");
document.write("<input type=hidden name=real value=6>");
document.write("<input type=hidden name=misc value=4>");
document.write("<input type=button value='=' onclick='Total(this.form)'>");
document.write("<input type=text name='total'>");
document.write("</form>")
</script>
Or simply try capitalize your function names.
Thanks, but I've already got it sorted now anyway... you can see it on the graphics section of my site - link below - if you are really interested
- Will
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks