ainoy31 Posted January 12, 2008 Share Posted January 12, 2008 Hello- I have a form that I use javascript to total up the total cost. I need to post the total cost data to another page. I am using the span tag to capture it. Here is my code: Javascript: function add_buy() { $('input.buy').keyup(function() { total_buy = 0; $('tr.group').each(function() { buy = $(this).find('input.buy').val(); total_buy = total_buy + Number(buy); buy_sum = $('span.total_buy'); buy_sum.text(total_buy,true); }); }); }//end of function add_buy() The form code is: <table> <tr> <td> <label for="total_buy">Total Buy Price:</label> <input type="hidden" name="total_buy" id="total_buy" /><span class='total_buy'> 0</span> </td> </tr> I tried using the $_POST['total_buy'] or $_REQUST['total_buy'] but no luck. I am missing something stupid here. Much appreciation. AM Link to comment https://forums.phpfreaks.com/topic/85650-solved-posting-data/ Share on other sites More sharing options...
Ken2k7 Posted January 12, 2008 Share Posted January 12, 2008 Okay a few things. 1. I don't get your jQuery code. I don't see input.buy or tr.group. 2. You need to make a form to submit it to another page. <table> <tr> <td> <form method='post' action='site.php'> <label for="total_buy">Total Buy Price:</label> <input type="hidden" name="total_buy" id="total_buy" /><span class='total_buy'> 0</span> <input type='submit' value='Submit' name='submit' /> </td> </tr> Replace site.php with your site. Then on that site, you can use $_POST['total_buy']; Does this help? Link to comment https://forums.phpfreaks.com/topic/85650-solved-posting-data/#findComment-437110 Share on other sites More sharing options...
ainoy31 Posted January 21, 2008 Author Share Posted January 21, 2008 In my javascript I use document.getElementById('total_sell').value = num; and document.getElementById('total_buy').value = num; for the input text area I use this segment of code: <td> <label for="total_buy">Total Buy Price:</label> <input type="text" name="total_buy" size="15" class="readonly" id="total_buy" READONLY> <!--<span class='total_buy'> 0</span>--> </td> </tr> <tr> <td> <label for="total_sell">Total Sell Price:</label> <!--<span class='total_sell'> 0</span>--> <input type="text" name="total_sell" size="15" class="readonly" id="total_sell" READONLY> </td> Link to comment https://forums.phpfreaks.com/topic/85650-solved-posting-data/#findComment-445553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.