putradnata

Define Value from Select Option using Ajax

Jul 27th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     $(document).ready(function(){
  3.         $("#your_select_id").change(function(){ //select box change function event
  4.             var new_variable = $("#your_select_id").val(); // create new variable and get the value from your select box
  5.             $.ajax({ //ajax
  6.                 url: "your_process_page.php", //link to your process page
  7.                 data: "new_variable="+new_variable, //which data will transfer to process page, dont forget to add $_GET['new_variable']; in your process page
  8.                 cache: false,
  9.             })
  10.             .done(function(ajaxresults){
  11.                 $("#your_defined_input").val(ajaxresults); //make your defined input to set its value depend to result of the process before
  12.             });
  13.         });
  14.     });
  15. </script>
Advertisement
Add Comment
Please, Sign In to add comment