## Easy Percentage Calculator HELP

Javascript coding ..

Moderators: macek, egami, gesf

Reveal
New php-forum User
Posts: 1
Joined: Sun Jul 15, 2012 2:00 am

### Easy Percentage Calculator HELP

So here is my code so far:

Code: Select all

`<SCRIPT language=JavaScript>function perc1() { a = document.form1.a.value/100; b = a*document.form1.b.value; document.form1.total1.value = b }function perc2() { a = document.form1.c.value; b = document.form1.d.value; c = a/b; d = c*100; document.form1.total2.value = d }</SCRIPT>`

Code: Select all

`<div><span style="font-size: 24px; font-weight: bold; text-decoration: underline;"><br />    </span>  <form name="form1">    <table cellspacing="1" cellpadding="1" border="0">      <tbody>        <tr>          <td>Exchanges under \$100 =             <input type="hidden" size="5" value="25" name="a" />25% of             <input size="5" name="b" />? </td>          <td>Answer:             <input maxlength="40" size="5" name="total1" disabled="disabled" /></td>          <td>            <input onclick="perc1()" type="button" value="Calculate" /></td>        </tr>      </tbody>    </table>  </form></div>`

This basically works out 25% of the input, now how I do make a new tr tag that will auto substract the input(b) - the percentage answer (total1)

Nullsig
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

### Re: Easy Percentage Calculator HELP

You need to add a row to the table?