0

I am trying to create a web site with a table of results that will have a drop down box at the end of each row that will let you select a quantity you would like of that row. In my case the user could have thousands of results based on their search criteria with a possibly large and variable amount of results on the page at one time.

I want to use an onchange or similar method to immediately update each change in the background (update query to table) without reloading the page. No other information on the page will change and it would be an unnecessary delay to the user to reload the page, especially with all the pulls from tables that would mean.

I have been searching the net for several days now, and finally figured out how to get the information extracted on which drop down was changed and what it was changed to in JavaScript.

I haven't found how to trigger my update SQL command without reloading a page. Can someone please tell me how I get the variables I just extracted to an SQL update without reloading the page?

Here is what I have so far. Any help would be appreciated.

function quantityfunction(select)
{
    var selectedOption = select.options[select.selectedIndex];      
    alert (\"The selected option is \" + selectedOption.value);

}//alert is only for testing

</script>

<?php
echo"<SELECT onChange=\"quantityfunction(this)\">";
while($temp<101)
{
echo"<OPTION VALUE='$item-$temp'>$temp";
$temp++;
}
</select>
?>
  • 2
    http://en.wikipedia.org/wiki/Ajax_%28programming%29 – Marc B Apr 24 '14 at 21:02
  • As per the discussion on Sam's answer, you can do this in raw JavaScript, but I'd advise using a library. If you are willing to try one, search for "jQuery AJAX PHP" and try some examples - you are sure to find loads. – halfer Apr 24 '14 at 21:20
  • Does a library mean opening up to security issues or a perform hit? The thought of using a black box raises questions. I like to see, and better yet understand all code run on my site. – user3558529 Apr 24 '14 at 22:18

0 Answers0