User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,513 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,116 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 4829 | Replies: 2
Reply
Join Date: Sep 2004
Location: Cheltenham, UK
Posts: 20
Reputation: TimmyRaa is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
TimmyRaa's Avatar
TimmyRaa TimmyRaa is offline Offline
Newbie Poster

Dynamic calculations on form

  #1  
Mar 9th, 2005
I have a form where you select a player's name from a drop down list, and there are 6 input boxes next to it for their separate scores and a box at the end for their total score (all the separate scores summed).

I want to have the form dynamically calculate the total as you move between each field (or even just after the last field), and display it at the end of the row. The code for the first player is below:

Player 01 Name: 
<SELECT NAME=playerid1>
<OPTION VALUE=0>Select Player...
<?=$options?>
</SELECT>

<input type="text" name="p1h1" id="p1h1" size=1><input type="text" name="p1h2" id="p1h2" size=1><input type="text" name="p1h3" id="p1h3" size=1><input type="text" name="p1h4" id="p1h4" size=1><input type="text" name="p1h5" id="p1h5" size=1><input type="text" name="p1h6" id="p1h6" size=1> Total: <input type="text" name="score1" id="score1" size=2>
I've tried the few methods I have seen around the net, but none of the example coding works - in IE I get script errors, and in Firefox nothing happens at all.

It looks fairly simple to do if you have knowlege of JavaScript; just put the calculation method at the top, and call it via an onblur="total()" or similar in the form input thing.

Can anyone help? Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Dynamic calculations on form

  #2  
Mar 9th, 2005
Originally Posted by TimmyRaa
I have a form where you select a player's name from a drop down list, and there are 6 input boxes next to it for their separate scores and a box at the end for their total score (all the separate scores summed).

I want to have the form dynamically calculate the total as you move between each field (or even just after the last field), and display it at the end of the row. The code for the first player is below:

Player 01 Name: 
<SELECT NAME=playerid1>
<OPTION VALUE=0>Select Player...
<?=$options?>
</SELECT>

<input type="text" name="p1h1" id="p1h1" size=1><input type="text" name="p1h2" id="p1h2" size=1><input type="text" name="p1h3" id="p1h3" size=1><input type="text" name="p1h4" id="p1h4" size=1><input type="text" name="p1h5" id="p1h5" size=1><input type="text" name="p1h6" id="p1h6" size=1> Total: <input type="text" name="score1" id="score1" size=2>
I've tried the few methods I have seen around the net, but none of the example coding works - in IE I get script errors, and in Firefox nothing happens at all.

It looks fairly simple to do if you have knowlege of JavaScript; just put the calculation method at the top, and call it via an onblur="total()" or similar in the form input thing.

Can anyone help? Thanks!

Link me to the HTML (or attach it)
Reply With Quote  
Join Date: Sep 2004
Location: Cheltenham, UK
Posts: 20
Reputation: TimmyRaa is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
TimmyRaa's Avatar
TimmyRaa TimmyRaa is offline Offline
Newbie Poster

Re: Dynamic calculations on form

  #3  
Mar 9th, 2005
I've PM'd you the link to it. I will post the solution for others (if I find it) later, once I've stripped out my password and stuff from the code!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:59 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC