Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 482
  • Last Modified:

Syntax of a Javascript

Hi,

I want to show 3 results on my webpage using the following javascript. Currently, I am able to show the value of result1, but when I add the code for the other 2 results it does not do anything. Can anyone help me with the syntax of the following javascript so that I can get all 3 results?

<script type="text/javascript">

function calculateList()
{
var op1=document.getElementById('Volume');
var op2=document.getElementById('CashBackRate');
var op3=document.getElementById('TradesPerDay');
var result1=document.getElementById('MonthlyRebateAmount1');
var result2=document.getElementById('YearlyRebateAmount1');
var result3=document.getElementById('YearlyPips1');
result1.value=0;
result1.value=parseFloat(result1.value);
result2.value=0;
result2.value=parseFloat(result2.value);
result3.value=0;
result3.value=parseFloat(result3.value);

result1.value=((21*parseFloat(op1.value)*parseFloat(op2.value)*parseFloat(op3.value))/10);
result2.value=((12*21*parseFloat(op1.value)*parseFloat(op2.value)*parseFloat(op3.value))/10);"
result3.value=(((21*parseFloat(op1.value)*parseFloat(op2.value)*parseFloat(op3.value))/10)/10);"
}
</script>
0
spiral2007
Asked:
spiral2007
1 Solution
 
Tom BeckCommented:
Could it be the quotes at the end of these two lines?

result2.value=((12*21*parseFloat(op1.value)*parseFloat(op2.value)*parseFloat(op3.value))/10);"
result3.value=(((21*parseFloat(op1.value)*parseFloat(op2.value)*parseFloat(op3.value))/10)/10);"
0
 
WebDevEMCommented:
Hi Spiral,

The code itself looks good, but there are extra quotes at the end of the last 2 lines (result2.value = and result3.value=)

I've set up a Fiddle where you can see it working and drop in your values to test it.  Take a look at http://jsfiddle.net/webdevem/9dK2y/.  Once you're done with this problem, I'll take the fiddle down, but I hope this helps!

WebDevEM
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now