dstafford Posted August 22, 2008 Share Posted August 22, 2008 Sorry all...nubie question. Just getting into scripting in HTML pages and I am running into a brick wall.I have a simple form that have 4-5 text input boxes that go to a database, however I would like the form to display a "running total" box. The form handles some hours that people spend on some projects and I would like to show the total as they update each days' time. I know I need to utilize the onchange property somehow but I am not grasping the concept of how to pass the current value to the function and keep the total updated.Any assitance would be appreciated.Thanks Link to comment Share on other sites More sharing options...
aspnetguy Posted August 22, 2008 Share Posted August 22, 2008 here is a rough layout <input type="text" name="field1" id="field1" onblur="calculate()" /><input type="text" name="field2" id="field2" onblur="calculate()" /><input type="text" name="field3" id="field3" onblur="calculate()" /><input type="text" name="field4" id="field4" onblur="calculate()" /><input type="text" name="field5" id="field5" onblur="calculate()" /><input type="text" name="total" id="total" /><script type="text/javascript"> function calculate() { var field1 = document.getElementById('field1').value; var field2 = document.getElementById('field2').value; var field3 = document.getElementById('field3').value; var field4 = document.getElementById('field4').value; var field5 = document.getElementById('field5').value; var total = document.getElementById('total'); //add your five fields together //var sum = ... //write out the total total.value = sum; }</script> Link to comment Share on other sites More sharing options...
dstafford Posted August 22, 2008 Author Share Posted August 22, 2008 Thanks for the help.Any guidance as to what would be a good reference for learning scripting? Most of the info I come across either is to basic or does not give real good examples of how to use in real world problems.Like the COD4 avatar. Link to comment Share on other sites More sharing options...
Kingy Posted August 22, 2008 Share Posted August 22, 2008 You did go through the w3schools tutorials yes? Personally I think google is your best bet. Just search __something__ javascript and you'll usually find tutorials and forum help. Link to comment Share on other sites More sharing options...
aspnetguy Posted August 22, 2008 Share Posted August 22, 2008 Thanks for the help.Any guidance as to what would be a good reference for learning scripting? Most of the info I come across either is to basic or does not give real good examples of how to use in real world problems.Like the COD4 avatar.Quirksmode http://www.quirksmode.org/ is great for indepth tutorials but like was already mentioned, Google is great.Do you play COD4? Link to comment Share on other sites More sharing options...
dstafford Posted August 22, 2008 Author Share Posted August 22, 2008 Yes...and actually they were a great start but everything I find seems to jump from a good start to mega-deep, esoteric coding. Looking for a good next step in the learning process.Thanks Link to comment Share on other sites More sharing options...
dstafford Posted August 22, 2008 Author Share Posted August 22, 2008 I do play COD4..... love that game. spending a lot of time getting killed :)Thanks again for the help Quirksmode http://www.quirksmode.org/ is great for indepth tutorials but like was already mentioned, Google is great.Do you play COD4? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 23, 2008 Share Posted August 23, 2008 I do play COD4..... love that game. spending a lot of time getting killed Thanks again for the helpIt is great I have been spending a lot of time at the TOOL Zombie server lately ( http://toolclan.com/ ). If you check it out look me up (I'm {FHR}WidowMaker) Link to comment Share on other sites More sharing options...
Synook Posted August 23, 2008 Share Posted August 23, 2008 DarthVader, I see you like Portal a lot too :)If you like using frameworks, http://nettuts.com/category/javascript-ajax/ is a good site. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2008 Share Posted August 23, 2008 Did someone mention Valve? Link to comment Share on other sites More sharing options...
dstafford Posted August 25, 2008 Author Share Posted August 25, 2008 Why yes I believe they did.... There will be cake. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 25, 2008 Share Posted August 25, 2008 Liar. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.