tom92 Posted December 5, 2008 Share Posted December 5, 2008 Okay... I'm sort of an aax newbie. I wrote up this small script. Basicly what it does is sends the numeric value to the php file and then inserts that value into Mysql. I can do that fine but then when I try to display the SUM() of all the values i'm having problems. Here's my script... <html> <head> <script type="text/javascript"> function XMLHttp(){ // XMLHttp Request here... } var ajaxRequest; function insertValue(value){ ajaxRequest.open("GET","insertValue.php?value=" + value,true); ajaxRequest.send(null); } </script> </head> <body> <p id="show_total"><!-- This where i'd want to show the SUM() of all the values --></p> <a href="javascript:insertValue(5)">Add value</a> </body> </html> Okay theres the code. When the user hits the Add value link I want to display the total inside the p tags. Quote Link to comment Share on other sites More sharing options...
corbin Posted December 6, 2008 Share Posted December 6, 2008 So uh.... What have you tried? Or do you not even know where to start? Quote Link to comment Share on other sites More sharing options...
tom92 Posted December 6, 2008 Author Share Posted December 6, 2008 No to be honest i'm stuck on this one... lol Quote Link to comment Share on other sites More sharing options...
corbin Posted December 6, 2008 Share Posted December 6, 2008 Read an AJAX tutorial or two. This isn't hard at all. Quote Link to comment Share on other sites More sharing options...
priti Posted December 10, 2008 Share Posted December 10, 2008 in insertValue.php file write a query which return sum of the field and return the response to you Hint :SUM() is a function in mysql when the response will received at client end in responseText you can do something like if(readystate == 4) { document.getElementById('show_total').value=responseText } i think above hints are sufficient for you to start !!! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.