Jump to content

How do I organize multiple functions for .onsubmit?

Recommended Posts

I can't figure out why these three functions aren't working. They only work one at a time. How do I run multiple functions on a .onsubmit? What's the syntax?

function calculate()


var quantity = parseFloat(document.getElementById("EditRecordDirectory_Quan").value);

var price = parseFloat(10);

var total = parseFloat(quantity * price);

var quantity2 = parseFloat(document.getElementById("EditRecordBrick_Quan").value);

var price2 = parseFloat(50);

var total2 = parseFloat(quantity2 * price2);

if (document.getElementById('EditRecordGuardian_Membership').checked)

{document.getElementById('EditRecordMembership_Fees').value = 15;}


{document.getElementById('EditRecordMembership_Fees').value = 0;}


{document.getElementById("EditRecordDirectory_Fees").value = 0;}


{document.getElementById("EditRecordDirectory_Fees").value = Math.round(total);}


{document.getElementById("EditRecordBrick_Fees").value = 0;}


{document.getElementById("EditRecordDirectory_Fees").value = Math.round(total2);}



Link to comment
Share on other sites

hi VVMustang,

I think the way that you are writing your script is correct.

One thing you have to make sure is: when you use the fields in javascript, make those fields either 'hidden' or 'text field' or any other 'Form element' . But do NOT make it 'Display only'. Because 'Display only' fields cannot be edited.

For debugging your code, you can write alert statement after each if else statement.

For eg.: if(..){...}else{...} alert('after first if '); Similarly, you can write for others.

If you still have problem, paste the script with alert statement and if the alert is produced or not.

Also, install firebug add-on in your Firefox browser. It will show you the javascript error if you have any. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...