# Calculate Percent completed and Total Value of Dropdown

## Recommended Posts

My Update form has 7 dropdown fields (Q1 – Q7) in which Rate/Yes/No options have corresponding numeric values. (Rate=No - No value, Yes=5, No=0) .
We need help in 2 things.
1. Calculate and store the total Value of all the fields.To Calculate and store the total value of the Q1 – Q7 dropdown, we use the following script in the footer of the update form, (but it seems that it's not working)

<SCRIPT LANGUAGE="JavaScript">

function calculate()
{
var Q1 = parseInt(document.getElementById("EditRecordQ1").value);
var Q2 = parseInt(document.getElementById("EditRecordQ2").value);
var Q3 = parseInt(document.getElementById("EditRecordQ3").value);
var Q4 = parseInt(document.getElementById("EditRecordQ4").value);
var Q5 = parseInt(document.getElementById("EditRecordQ5").value);
var Q6 = parseInt(document.getElementById("EditRecordQ6").value);
var Q7 = parseInt(document.getElementById("EditRecordQ7").value);

QRating=parseInt( Q1 + Q2 + Q3 + Q4 + Q5 + Q6 + Q7);

document.getElementById("EditRecordReferral_Rating").value = QRating;
}

document.getElementById("caspio").onsubmit=calculate;
</SCRIPT>

2. Calculate and store get the Percentage of the answered questions. --> Need help on this.

##### Share on other sites

Hi!

Can you try changing the last line to:

`document.getElementById("caspio").onsubmit=calculate();`

##### Share on other sites

The last line should be

`document.getElementById("caspioform").onsubmit=calculate;`

Also you need to make sure you do not have any blank value. In first dropdown you have Rate which is blank for value. Make sure to make all dropdowns required so they have to choose a value

Did that help?

##### Share on other sites

This worked.. Thank you MayMusic!

You are welcome!

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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