js常见表单应用技巧
时间:2021-07-01 10:21:17
帮助过:3人阅读
显示框架内的指定位置
<div style='width:300px;height:300px;'><iframe src='http://163.com' style='margin:-100px;width:100%;height:100%'></iframe></div>
改变文本框的属性(确定按钮)
<form id="form1" name="form1" method="post" action="">
<input name="text" type="text" value="sdafasdfasdf" id="name"/>
<input type="button" name="Submit" value="更改" onClick="tot()"/>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!--
function tot()
{
if (document.form1.name.disabled == true)
{
document.all.name.disabled=false;
}
else
{
document.all.name.disabled=true;
}
}
//-->
</SCRIPT>
注:以下的readOnly的O必须为大写r必须为小写
<SCRIPT LANGUAGE="JavaScript">
<!--
function tot()
{
if (document.all.name.readOnly == true)
{
document.all.name.readOnly=false;
}
else
{
document.all.name.readOnly=true;
}
}
//-->
</SCRIPT>
改变文本框的属性(单选按钮)
<script language="javascript">
<!--
function cStyleshow()
{
document.all.name.disabled=false;
}
function cStylehidde()
{
document.all.name.disabled=true;
}
-->
</script>
<input name='a1' type='radio' value='yes' checked onclick='cStyleshow()'>1
<input name='a1' type='radio' value='no' checked onclick='cStylehidde()'>2
<input name="name" type="text" id="name">
改变文本框的属性(下拉列表)
<select name="s1" onChange="if(this.value==1){document.all('T1').readOnly=true}else{document.all('T1').readOnly=false}">
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="text" name="T1"/>