php - Retrieving value of a select box populated by an ajax call -
here 2 select boxes. trying value of c pass on in form. select box c populated ajax call below can't seem useable value pass on form. (in simplest form looking var a= 'select box c') can send 'a' in form:
many in advance people x
<select name="list-select" id="list-select"> <option value="">please select..</option> <option value="chemical">chemical</option> <option value="hardware">hardware</option> </select> <select name="c" id="c"></select>
here jquery bit:
<script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).ready(function ($) { var list_target_id = 'c'; //first select list id var list_select_id = 'list-select'; //second select list id var initial_target_html = '<option value="">please select colour...</option>'; //initial prompt target select $('#' + list_target_id).html(initial_target_html); //give target select prompt option $('#' + list_select_id).change(function (e) { //grab chosen value on first select list change var selectvalue = $(this).val(); //display 'loading' status in target select list $('#' + list_target_id).html('<option value="">loading...</option>'); if (selectvalue == "") { //display initial prompt in target select if blank value selected $('#' + list_target_id).html(initial_target_html); } else { //make ajax request, using selected value $.ajax({ url: 'http://www.mypropertyviewing.com/client_order_form_v1.1/selector.php?svalue=' + selectvalue, success: function (output) { $('#' + list_target_id).html(output); }, error: function (xhr, ajaxoptions, thrownerror) { alert(xhr.status + " " + thrownerror); } }); } }); }); </script>
use
selectvalue=this.value //instead of selectvalue =$(this).val();
Comments
Post a Comment