<input type="radio" name="a" value="0" onclick="if(this.checked) document.getElementById('b').style.display='';" checked>显示
<input type="radio" name="a" value="1" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
<input type="radio" name="a" value="2" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
<input type="radio" name="a" value="3" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
<div id="b"><input><input><input></div>document.getElementById('xxx')用来获取id为xxx的对象。
style表示对象的样式
display表示显示的方式,其取值为空时表示显示,取none表示不显示

解决方案 »

  1.   

    <input type="radio" name="a" value="0" onclick="if(this.checked) document.getElementById('b').style.display='';" checked>显示
    <input type="radio" name="a" value="1" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
    <input type="radio" name="a" value="2" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
    <input type="radio" name="a" value="3" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
    <div id="b"><input><input><input></div>******************以上是写在form里面吗?
    那要插入的text框那?
      

  2.   

    放不放在form里都可以,看你的需求而定了。
    如果是在form里,可以用name引用。不放在form里就像上面的例子一样用id引用。
      

  3.   

    不好意思,又来打扰了。下面这段代码为什么没有显示内容?text 框这样写可以吗?<body> <b><h1> This is my js3-page.htm! </h1></b>

    <form>
    <table width="99%" border="0" cellspacing="0" cellpadding="0" class="box">
    <tr>
    <td class=form_th colspan=2>订单</td>
    </tr>
    <tr></tr><tr></tr>
    <tr>
    <th><span class="box_th">类型</span></th>

    <input type="radio" name="a" value="0" onclick="if(this.checked) document.getElementById('b').style.display='';" checked>显示

    <input type="radio" name="a" value="1" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示

    <input type="radio" name="a" value="2" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示

    <input type="radio" name="a" value="3" onclick="if(this.checked) document.getElementById('b').style.display='none';">不显示
    </tr>
    <div id="b">
    地址1:<input type="text" name="add1" value="上海" />
    地址2:<input type="text" name="add1" value="北京" />
    地址3:<input type="text" name="add1" value="武汉" />
    </div>


    </table>
    </form>
    </body>
      

  4.   

    这一段:
    <div id="b">
    地址1:<input type="text" name="add1" value="上海" />
    地址2:<input type="text" name="add1" value="北京" />
    地址3:<input type="text" name="add1" value="武汉" />
    </div>
    改成:
    <tr id="b"><td>
    地址1:<input type="text" name="add1" value="上海" />
    地址2:<input type="text" name="add1" value="北京" />
    地址3:<input type="text" name="add1" value="武汉" />
    </td></tr>