日期:2014-05-16  浏览次数:20391 次

新手上路:怎么选择other选项就出现other文本框?(100分)
我asp页面里有一个问题,可以选择其他项,然后填写。我想不勾这个other时候,那个文本框就隐藏,勾上以后就出现那个框让用户填写。怎么写啊?
<p>1.你为什么喜欢上网?
  <input type="checkbox" name="Q3" value="1"> Contact information </label>
  <input type="checkbox" name="Q3" value="2" > Other</label>
  <br>
 Please specify:&nbsp;<input type="text" name="Q3Other" style="width:300px">br>

------解决方案--------------------
<p> 1.你为什么喜欢上网?
<input type= "checkbox" name= "Q3" value= "1"> Contact information </label>
<input type= "checkbox" name= "Q3" value= "2" onclick="this.checked==true?text1.style.display='':text1.style.display='none';"> Other </label>
<br>
Please specify:<input type= "text" id="text1" name= "Q3Other" style= "width:300px;display:none"> <br>
------解决方案--------------------
CSS的style.display属性可以用来控制控件的显示。

相关网站和例子:
http://msdn2.microsoft.com/en-us/library/ms530751.aspx
------解决方案--------------------
HTML code
<p> 1.你为什么喜欢上网?
  <label><input type= checkbox  name= Q3 value="1">Contact information</label>
  <label><input type= checkbox  name= Q3 value="2" onClick="document.getElementById('Q3Other').parentNode.style.display=this.checked?'block':'none'">Other</label>
  <div style="display:none;">Please specify:&nbsp;<input type="text" name="Q3Other" style="width:300px"></div>
</p>

------解决方案--------------------
人家都给你正解了!
------解决方案--------------------
HTML code
<p> 1.你为什么喜欢上网?
  <label><input type= checkbox  name= Q3 value="1">Contact information</label>
  <label><input type= checkbox  name= Q3 value="2" onClick="document.getElementById('Q3Div').style.display=this.checked?'block':'none'">Other</label>
  <div id="Q3Div" style="display:none;">Please specify:&nbsp;<input type="text" name="Q3Other" style="width:300px"></div>
</p>