Forum for users of JoomlaWatch / ExtraWatch for Joomla, Wordpress, Drupal, Magento, Prestashop

JoomlaWatch / ExtraWatch has following features: live real-time visitor statistics, location of your visitors on a map, blocking of users based on bad word list, front-end counters, click heat map, definition of goals and rules, graphs, directory size monitoring, monitoring of increase of database data in time, nightly email reports, interactive HTML5 chart of traffic flow within your website, SEO report with keyword statistics and keyword position trends

Welcome, Guest
Please Login or Register.    Lost Password?

Help me with this simple calculation Javascript!!
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Help me with this simple calculation Javascript!!
#319
Help me with this simple calculation Javascript!! 8 Years, 11 Months ago  
Hi, I'm new at programming, I will appreciate your help...
Basically I have an radio and a select input areas that send their value to the respectives text areas, until here I got it working, but then I have a third text area where should show the sum of both. I tried to use an onChange event to call the function that should make the sum and show the result, but It doesn't work.
Here the code, I included the whole page so you can easily try it if you wish
Code:


<html><head><title>TOTAL CALCULATION</title>
  <script language="JavaScript" type="text/javascript">
<!--
function setPrintSize(printsize){
printform.printcost.value = printsize;
}
function setShippingCost(){
printform.shipcost.value = printform.shipping.value;
}
function total(){
$s = printform.shipping.value;
$p = printform.printcost.value;
printform.total.value = $s + $p;
}
-->
  </script>
</head>
<body>
<form id="printform" name="printform" method="post" 

action="live.php">           
  <!--sets print price-->  
<input name="print" value="11x17" type="radio" 

onclick="setPrintSize('4')" />
<input name="print" value="15x22" type="radio" 

onclick="setPrintSize('5.50')" />
<input name="print" value="radiobutton" type="radio" 

onclick="setPrintSize('7')" /><br /><br />
       <!--sets shipping costs--> 
 <select name="shipping" id="shipping" 

onChange="setShippingCost()">
              <option selected="selected" value="0">SELECT 

YOUR LOCATION</option>
              <option value="4">SPAIN</option>
              <option value="6">EUROPE</option>
              <option value="8">AMERICA & REST
OF THE WORLD</option>
              </select><br /><br />
  
<!--shows costs and totalize-->    
  
print price=<input name="printcost" id="printcost" size="6" 

onfocus="this.form.elements[0].focus()" onChange="total()" 

type="text" /><br />

shipping=<input name="shipcost" id="shipcost" size="6" 

onfocus="this.form.elements[0].focus()" onChange="total()" 

type="text" /><br />

TOTAL=<input name="total" id="total" size="6" 

onfocus="this.form.elements[0].focus()" type="text" />

</form><body><html>



I also tried this:
Code:

 <script language="JavaScript" type="text/javascript">
<!--
function setPrintSize(printsize){
printform.printcost.value = printsize;
total();
}
function setShippingCost(){
printform.shipcost.value = printform.shipping.value;
total();
}
function total(){
$s = printform.shipping.value;
$p = printform.printcost.value;
$total = $s + $p;
printform.total.value = $total;
}
-->
  </script>



Any help will be highly appreciated.
ultramood (Visitor)

The administrator has disabled public write access.
 
Go to topPage: 1