dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: :-o help needed javascript newbies!

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    :-o help needed javascript newbies!

    im creating a website and i have input fields which the user will enter numbers between 0-250. i need to create something which will totalise the numbers they input without having to refresh the page.

    any help would be greatly appreciated.

    x


  2. #2
    Join Date
    Nov 2003
    Location
    Worthington, OH, USA
    Posts
    3,634
    One way:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Test</title>
    <script type="text/javascript">
    function runningTotal(val) {
    	val=parseInt(val);
    	rtotal=document.getElementById("total");
    	if (val < 0 || val > 250) {
    		val = 0;
    		alert("Invalid Number");
    	}
    	rtotal.value = parseInt(rtotal.value)+val;	
    }
    
    </script>
    </head>
    <body>
    <input type="text" onchange="runningTotal(this.value);this.value=''" />
    <input type="text" disabled="disabled" id="total" value="0"/>
    </body> 
    </html>
    54 68 65 42 65 61 72 4D 61 79

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles