how to use javascript variable value in jsp?

Javascript:depreciation calculator?

  • I am new to using javascript.this is exactly what i need except i want to use combobox instead of the textbox "number of years to depreciate over" .can some one help me how to add three items such as item1 - 5 year, item2 - 10 year, item3 - 15 year, when user selet item1 - 5 year, it will calculate using 5 year as <b>Number of years to depreciate over</b>. <html> <head> <!--Paste this section of the code in the <HEAD> section of your webpage--> <script language="JavaScript" type="text/javascript"> <!-- function straight() { var depreciation = document.straightline.historicalcost.val… / document.straightline.years.value; var depreciation = depreciation.toFixed(2); document.straightline.depreciation.val… var monthlydepreciation = document.straightline.depreciation.value / 12; var monthlydepreciation = monthlydepreciation.toFixed(2); document.straightline.monthlydepreciat… var months = document.straightline.years.value * 12; var months = months.toFixed(0); document.straightline.months.value=mon… months"; } // --> </script> <!--End of code to be pasted in the <HEAD> section of your webpage--> <!--Paste this section of the code in the <BODY> section of your webpage--> <form name="straightline"> <table width="100%" bgcolor="#6f8599"> <tr> <td colspan="2"> <b><font color="white">Straight Line Depreciation Calculator</b> - <i>(JavaScript)</i></font> </td> </tr> <tr> <td class="calculator"> <B>Historical Cost of Goods</b> </td> <td class="calculator"> <input name="historicalcost" size="10" value="0.00" style="font-size= 14pt" onFocus="select();" /> </tr> <tr> <td class="calculator"> <b>Number of years to depreciate over</b> </td> <td class="calculator"> <input name="years" size="10" value="0" style="font-size= 14pt" onFocus="select();" /> </td> </tr> <tr> <td colspan="2" align="center" valign="center"> <input type="button" value="Calculate" style="font-size= 12pt" onClick="straight();" />      <INPUT TYPE="RESET" NAME="Reset" VALUE=" Reset " style="font-size= 12pt" onClick="straight();" /> </td> </tr> <tr> <td class="calculator"> <B>Annual Depreciation Amount</b> </td> <td class="calculator"> <input name="depreciation" size="10" value="" style="font-size= 14pt" /> </td> </tr> <tr> <td class="calculator"> <B>Monthly Depreciation Amount</b> </td> <td class="calculator"> <input name="monthlydepreciation" size="10" value="" style="font-size= 14pt" /> </td> </tr> <tr> <td class="calculator"> <B>Depreciation Period = </b> </td> <td class="calculator"> <input name="months" size="10" value="" style="font-size= 14pt" /> </td> </tr> <tr> <td colspan="2"> Written by <a href="http://www.online-calculators.co.u… </td> </tr> </table> </form> <!--End of code to be pasted in the <BODY> section of your webpage--> </head> </html>

  • Answer:

    And this has what to do with taxes? btw: There is an error in line 49 of the script so it doesn't work.

David Solerez at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.