我正在使用此javascript和php代码在keyup上传递输入字段的值。工作正常。但我想添加一些单选按钮,并且无法传递其值。我正在使用的代码是:的HTML<div class="header-right"><input style="width:150px;" id="searchData" type="text"><br><input type="radio" id="advsrch" name="advsrch" value="name">Name<input type="radio" id="advsrch" name="advsrch" value="city">City</div>Java脚本$(document).ready(function(){ var advsrch = "";var selected = $("input[type='radio'][name='advsrch']:checked"); advsrch = selected.val();$('#results').html('<p style="padding:5px;">Enter a search term to start filtering.</p>'); $('#searchData').keyup(function() { var searchVal = $(this).val(); if(searchVal !== '') { $.get('search_data/search-data.php?searchData='+searchVal+advsrch, function(returnData) { if (!returnData) { $('#results').html('<p style="padding:5px;">Search term entered does not return any data.</p>'); } else { $('#results').html(returnData); } }); } else { $('#results').html('<p style="padding:5px;">Enter a search term to start filtering.</p>'); } });});然后在PHP中获得价值$param = $_GET["searchData"];$advsrch = $_GET["advsrch"];在这里,我获得了searchData的价值,但没有advsrch的价值 最佳答案 更新,(如下所示),经过测试,可以100%工作(提交了屏幕截图) 08-25 16:44