forms

Discussion in 'Javascript' started by Greg, Sep 19, 2005.

  1. Greg

    Greg Guest

    If i have a form and I want get the total and display it in a text field how
    can i do it i have tried have just <form name="myform"> but it stays there
    for about a second and then clears the form. If i have <form name="myform"
    method="post"> I get an error message and if i use <form name="myform"
    method="get"> its the same as <form name="myform">
     
    Greg, Sep 19, 2005
    #1
    1. Advertising

  2. Greg

    McKirahan Guest

    "Greg" <none> wrote in message news:...
    > If i have a form and I want get the total and display it in a text field

    how
    > can i do it i have tried have just <form name="myform"> but it stays there
    > for about a second and then clears the form. If i have <form name="myform"
    > method="post"> I get an error message and if i use <form name="myform"
    > method="get"> its the same as <form name="myform">



    What do you mean by "get the total"?

    Do you just want to use JavaScript to do a calculation?

    Will this help? Watch for word-wrap.

    <html>
    <head>
    <title>total.htm</title>
    <script type="text/javascript">
    function total() {
    var form = document.myform;
    var tot1 = form.my1.value;
    if (tot1 == "") return;
    var tot2 = form.my2.value;
    if (tot2 == "") return;
    form.tot.value = parseInt(tot1,10) + parseInt(tot2,10);
    }
    </script>
    <style type="text/css">
    ..rite { text-align:right }
    ..tots { text-align:right; background-color:#EEEEEE }
    </style>
    </head>
    <body onload="document.myform.my1.focus()">
    Enter number and press Tab to calculate Total.
    <br><br>
    <form name="myform">
    <input type="text" name="my1" size="8" maxlength="7"
    value="0" class="rite" onchange="total()">
    &nbsp;<b>+</b> &nbsp;
    <input type="text" name="my2" size="8" maxlength="7"
    value="0" class="rite" onchange="total()">
    &nbsp;<b>=</b> &nbsp;
    <input type="text" name="tot" size="8" maxlength="9"
    value="0" class="tots" readonly>
    </form>
    </body>
    </html>
     
    McKirahan, Sep 19, 2005
    #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. Brendan Miller

    Web Forms VS Windows Forms

    Brendan Miller, Aug 11, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,114
    Kevin Spencer
    Aug 11, 2003
  2. Eric
    Replies:
    2
    Views:
    1,523
    Tommy
    Feb 13, 2004
  3. jlopes151
    Replies:
    2
    Views:
    664
    Steve C. Orr [MVP, MCSD]
    Mar 14, 2005
  4. =?Utf-8?B?ZGF2aWQ=?=

    embedded windows forms into web forms for control

    =?Utf-8?B?ZGF2aWQ=?=, Apr 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,235
    =?Utf-8?B?ZGF2aWQ=?=
    Apr 10, 2005
  5. Eric
    Replies:
    2
    Views:
    595
Loading...

Share This Page