我有这段代码
<script type = "text/javascript">
$(document).ready(function(){
$(".sub_category").click(function()
{
var main_cat = $("input[name='category_form_cat_1']:checked").val();
var sub_cat_form1 = $("input[name='subcategory_form_cat_1']:checked").val();
$("input[name='subcategory_form_cat_1'][value=sub_cat_form1]").attr("checked",true);
$.ajax
({
data: {'cat':main_cat,'sub_cat':sub_cat_form1},
url: "ajax_files/events-select.php",
type: 'GET',
success: function(data)
{
$("#displayedresults").html(data);
$('#loading_spinner').hide();
$('#loading_text').hide();
$('#loading_row').hide();
$('#displayedresults').show();
//$('.button_export').show();
//$("a.button_export").attr("href", string);
}
});
return false;
});
});
我需要将此行值存储在下一个
中var sub_cat_form1 = $("input[name='subcategory_form_cat_1']:checked").val();
$("input[name='subcategory_form_cat_1'][value=sub_cat_form1]").attr("checked",true);
答案 0 :(得分:0)
你可以这样做
var sub_cat_form1 = $("input[name='subcategory_form_cat_1']:checked").val();
$("input[value="+sub_cat_form1 +"]").attr("checked",true);