Easy Percentage Calculator HELP

Javascript coding ..

Moderators: macek, egami, gesf

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

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

Code: Select all

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

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)

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

Re: Easy Percentage Calculator HELP

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

You need to add a row to the table?

Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest