Javascript ajax的示例需求,其中选择单选按钮将动态生成下拉列表
ajax的示例需求,选择单选按钮将动态生成下拉列表,您能再解释一下吗 你需要一个例子,如果你点击一个单选按钮并选择正在显示 如果是,则不需要ajaxJavascript ajax的示例需求,其中选择单选按钮将动态生成下拉列表,javascript,ajax,Javascript,Ajax,ajax的示例需求,选择单选按钮将动态生成下拉列表,您能再解释一下吗 你需要一个例子,如果你点击一个单选按钮并选择正在显示 如果是,则不需要ajax My radio: <input type="radio" name="YOUR_RADIO" onclick="document.getElementById('selectfield').style.display='';" /> <div id="selectfield" style="display:none"> <se
My radio: <input type="radio" name="YOUR_RADIO" onclick="document.getElementById('selectfield').style.display='';" />
<div id="selectfield" style="display:none">
<select><option>option</option></select>
</div>
我的收音机:
选项
祝你好运…如果你使用或可以使用,我会这样做:
拥有此HTML:
<input type="radio" name="myradio" value="foo" />
<input type="radio" name="myradio" value="bar" />
<input type="radio" name="myradio" value="baz" />
啊<代码>$我们多么爱你。好。不管怎样,写图书馆的人都喜欢它。如果您要依赖第三方库,那么值得一提的是哪一个库-尤其是作为不透明名称的
$
,原型和Moo工具(以及其他)OOP使用。。我发誓我读过jquery标签!真的很抱歉。我更新了我的答案。@David-在名为jQueryOverflow的网站上,显然是jQuery!(好吧,网站应该命名为…)看起来更好。如果您使用该方法的data参数而不是(不推荐使用的)escape函数,我将给您一个向上投票权。:)
$("input[@name='myradio']").change(function(){
var selected_value = $("input[@name='myradio']:checked").val();
$.getJSON("your_page.php", { value: selected_value }, populate_dropdown);
});
function populate_dropdown(items) {
// "items" is the ajax-loaded list based on the selected radio button.
// Clear the drop down, populate it and show it if hidden.
}