以下是两个选择框。我试图让C的值在表单中传递。选择框C是从下面的ajax调用中填充的,但我似乎无法获得可用的值传递给表单。 (在最简单的形式中,我正在寻找类似var A ='选择框C')然后我可以发送' A'形式如下:
非常感谢人们提前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>
这是jquery位:
<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 a colour...</option>'; //Initial prompt for target select
$('#' + list_target_id).html(initial_target_html); //Give the target select the prompt option
$('#' + list_select_id).change(function (e) {
//Grab the chosen value on first select list change
var selectvalue = $(this).val();
//Display 'loading' status in the 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 the selected value as the GET
$.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>
答案 0 :(得分:-1)
使用
selectvalue=this.value //instead of
selectvalue =$(this).val();