Tengo un problemita con un codigo simple que se supone me deberia calcular una cotizacion automaticamente segun los datos que ingresa el cliente.
Código HTML:
<html> <head> <script language="JavaScript"> function getQuotation(){ age=document.getElementById('age').value; //pickup=document.getElementById('pickup').value; return=document.getElementById('return').value; days=document.getElementById('days').value; total=0; rate=0; document.getElementById('admFee').innerHTML='0'; if(return=='Brisbane Airport'){ document.getElementById('airFee').innerHTML='30'; total=total+30; } else{ document.getElementById('airFee').innerHTML='0'; } rate=113-days; rate=rate/0.8; rate=days*rate; document.getElementById('carRental').innerHTML=rate; total=total+rate; document.getElementById('total').innerHTML=total; } </script> </head> <body> <form> <b>Driver's Age</b><br> <input type="text" id='age'> <br><b>Pick-Up</b><br> <select id='pickup'> <option>4WD Rent a Car Brisbane Office</option> <option>Brisbane Airport</option> </select> <br><b>Return</b><br> <select id='return'> <option>4WD Rent a Car Brisbane Office</option> <option>Brisbane Airport</option> </select> <br><b>How many days?</b><br> <input type="text" id='days' size="3"> <br><b>E-mail Address</b><br> <input type="text" id='email' size="15"> <br><br><input type="button" value="Get Quotation" onClick="getQuotation()"> </form> <p> <font color="#ff6600"><b>Your quotation</b></font> </p> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td><font face="arial,helvetica,sans-serif" size="1"><b> Car Rental: <br /> </b></font> </td> <td><font face="arial,helvetica,sans-serif" size="1">$ </font></td> <td id='carRental' align="right"><font face="arial,helvetica,sans-serif" size="1"> </font></td> </tr> <tr> <td><font face="arial,helvetica,sans-serif" size="1"><b> Administration Fee: <br /> </b></font></td> <td><font face="arial,helvetica,sans-serif" size="1">$<br /> </font></td> <td id='admFee' align="right"><font face="arial,helvetica,sans-serif" size="1"> </font></td> </tr> <tr> <td><font face="arial,helvetica,sans-serif" size="1"><b> Airport Fee:<br /> </b></font></td> <td><font face="arial,helvetica,sans-serif" size="1">$<br /> </font></td> <td id='airFee' align="right"><font face="arial,helvetica,sans-serif" size="1"> </font></td> </tr> <tr> <td><font face="arial,helvetica,sans-serif" size="1"><b> Other Fees (please refer to our rental agrement): <br /> </b></font></td> <td><font face="arial,helvetica,sans-serif" size="1">$<br /> </font></td> <td id='otherFee' align="right"><font face="arial,helvetica,sans-serif" size="1"> </font></td> </tr> <tr> <td><font color="#ff6600" face="arial,helvetica,sans-serif" size="1"> Total:</font></td> <td><font color="#ff6600" face="arial,helvetica,sans-serif" size="1">$<br /> </font></td> <td id='total' align="right"><font color="#ff6600" face="arial,helvetica,sans-serif" size="1"> </font></td> </tr> </tbody> </table> </body> </html>