我有两个单选框
Yes: <html:radio property="sel" value="value1"/>
No:  <html:radio property="sel" value="value2"/>另有一个下拉列表,我想实现当选中yes或no时,下拉列表中会出现与之关联的选项,要怎么做啊?
请高手指教!
谢谢!

解决方案 »

  1.   

    很简单,就是在每个radio添加onclick事件,onclick="javascript:show();"
    function show(){
    var selectElement=document.getElementById("selectID");
    var optionElement=document.createElement("option");
    optionElement.value=...;
    selectElement.appendChild(optionElement);
    }
      

  2.   

    To  zhangj0571(笨鸟飞飞):show()是返回什么类型的啊?
    能具体解释下show()函数吗?
      

  3.   

    show()不用返回任何信息,你可以根据radio的值,查询遍历,一次将option元素添加到select元素中
      

  4.   

    纯JS操作。这样处理吧。
    在单选按钮中加入onclick="javascript:showselectText();"
    function showselectText(){
     if(document.formname.sel[0].checked){
       document.formnameRooms.options[document.formname.selectfieldName.selectedIndex].text="TextXX11";
    document.formnameRooms.options[document.formname.selectfieldName.selectedIndex].value="ValueXX11";
     }else{
    document.formnameRooms.options[document.formname.selectfieldName.selectedIndex].text="TextXX22";
    document.formnameRooms.options[document.formname.selectfieldName.selectedIndex].value="ValueXX22";
     }
    }formname是表单名,selectfieldName是下拉列表域名,sel是你的单选按钮域名。你试一下,应该是这样的,我没有试,JS的东西,语法知道,多试几个就行了。有什么问题,再联系我(同时发消息)
      

  5.   

    to: szb110(子龙)我有两个下拉列表,想用下拉列表1控制下拉列表2,且下拉列表2的数据是从数据库中读取的 
    如何调用存储过程将数据传到下拉列表2中
      

  6.   

    你把代码发给我吧,我抽空帮你改一下。邮箱[email protected]