SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've made this simple script to automatically add up set numbers in hidden text boxes, but it doesn't work, and I don't know why. Could someone help me with this matter?

    The script follows...

    <script language="JavaScript">

    function total(form)
    { form.total.value = ((form.text.value*1)+(form.button.value*1)+(form.pro.value*1)+(form.real.value*1)+(form.misc.value*1)) }

    document.write("<form>");
    document.write("<input type=hidden name=text value=32>");
    document.write("<input type=hidden name=button value=10>");
    document.write("<input type=hidden name=pro value=5>");
    document.write("<input type=hidden name=real value=6>");
    document.write("<input type=hidden name=misc value=4>");
    document.write("<input type=button value='=' onClick=total(this.form)><input type=text name=total>");
    document.write("</form>");

    </script>

    - Will

  2. #2
    SitePoint Member Slash's Avatar
    Join Date
    Sep 2000
    Location
    Egypt
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the correct code of your script:

    function Total(form){
    form.total.value = (form.text.value*1)+(form.button.value*1)+(form.pro.value*1)+(form.real.value*1)+(form.misc.value*1)
    }
    document.write("<form>");
    document.write("<input type=hidden name=text value=32>");
    document.write("<input type=hidden name=button value=10>");
    document.write("<input type=hidden name=pro value=5>");
    document.write("<input type=hidden name=real value=6>");
    document.write("<input type=hidden name=misc value=4>");
    document.write("<input type=button value='=' onclick='Total(this.form)'>");
    document.write("<input type=text name='total'>");
    document.write("</form>")
    </script>

    Or simply try capitalize your function names.

  3. #3
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but I've already got it sorted now anyway... you can see it on the graphics section of my site - link below - if you are really interested

    - Will


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •