add text fields together...

Discussion in 'HTML' started by blackjack, Nov 28, 2006.

  1. blackjack

    blackjack Guest

    Hi,

    I'd like to use 2 text fields, and a button that when clicked , would add
    the 2 fields together and display as a line of text, can anyone help with
    this.

    Cheers
    bj
     
    blackjack, Nov 28, 2006
    #1
    1. Advertising

  2. blackjack

    Toby Inkster Guest

    blackjack wrote:

    > I'd like to use 2 text fields, and a button that when clicked , would add
    > the 2 fields together and display as a line of text, can anyone help with
    > this.


    <form method="get" action="<?= $_SERVER['PHP_SELF'] ?>"
    onsubmit="this.c.value=Number(this.a.value)+Number(this.b.value);
    return false;">
    <fieldset>
    <legend>Add things</legend>
    <input name="a" value="<?= (real)$_GET['a'] ?>"> +
    <input name="b" value="<?= (real)$_GET['b'] ?>">
    <input type="submit" value="=">
    <input name="c" value="<?= (real)$_GET['a'] + (real)$_GET['b'] ?>">
    </fieldset>
    </form>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Nov 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TOI DAY
    Replies:
    2
    Views:
    327
    TOI DAY
    Jul 11, 2003
  2. Cyril.Liu
    Replies:
    0
    Views:
    459
    Cyril.Liu
    Dec 2, 2008
  3. chief african brewer

    How to create a collection and add text fields

    chief african brewer, Jul 21, 2009, in forum: Java
    Replies:
    6
    Views:
    349
    John B. Matthews
    Aug 8, 2009
  4. Replies:
    4
    Views:
    166
    Tad McClellan
    Apr 30, 2006
  5. Replies:
    23
    Views:
    547
    Tim Streater
    Dec 18, 2013
Loading...

Share This Page