Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Easy Percentage Calculator HELP

Javascript coding ..

Moderators: macek, egami, gesf

Easy Percentage Calculator HELP

Postby Reveal » Sun Jul 15, 2012 2:05 am

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)
Reveal
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Jul 15, 2012 2:00 am

Re: Easy Percentage Calculator HELP

Postby Nullsig » Mon Jul 16, 2012 8:49 am

You need to add a row to the table?
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to JavaScript

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron