日期:2014-05-18  浏览次数:20395 次

问高手一个关于CheckBox使用期问题.
我在页面中放了两个控件,一个是CheckBox控件,一个是inptu上传图片的控件。现在我需要实现的功能是:当用户在浏览这个页面时,勾选了CheckBox时,input控件才能显示出来。请高手帮我写个代码(应该是什么事件/脚本才能实现吧?)
以下是页中的此部分代码

<asp:CheckBox   ID= "cbPic "   runat= "server "   Text= "图片新闻 "   />
                                                                        &nbsp;&nbsp;   &nbsp; <input   id= "filePic "   runat= "server "   onchange= "document.all.Image1.src=this.value "   type= "file "   style= "width:   255px "   name= "filePic "   /> (在新闻中心首页显示的图片) <br   />
                                                                        <asp:Image   ID= "Image1 "   runat= "server "   Height= "100px "   ImageUrl= "../images/none.jpg "
                                                                                Width= "90px "   />

------解决方案--------------------
<script language=javascript>
function display()
{
if(document.getElementById( "CheckBox1 ").checked)
document.getElementById( "file1 ").style.display = "block ";
else
document.getElementById( "file1 ").style.display = "none ";

}
</script>


<form id= "form1 " runat= "server ">
<div>
<input style= "display: none " type= "file " id=file1 />
<asp:CheckBox ID= "CheckBox1 " runat= "server " Text= "xczx "/>
</div>
</form>
后台pageload里写上
CheckBox1.Attributes.Add( "onclick ", "display() ");