关于浏览器的问题(急) 我在IE下可以运行的JS脚本(check.点击事件)~在火狐上为什么没用呢?请大侠帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function changeStatus(obj){ var txt=window.document.getElementById("cuxiaoPrice"); if(obj.checked) { txt.value=""; txt.disabled=false; } else { if(!obj.checked){ txt.value=0; } txt.disabled=true; }这是JS代码,意思就是如果checkBox被选中,文本框就可以输入,可我在火狐上点checkBox没效果 var txt=window.document.getElementById("cuxiaoPrice");//txt是文本框, 浏览器不一样导致的JS脚本不能正常运行,这很正常;就是同一种浏览器,比如IE,版本不一样,同样的JS脚本,在IE7中就能用而到IE6上就不行。 在火狐下选中check文本框还是默认的不可写有什么办法么? 没办法,FF下文本框disable的属性是只读的 你用css控制下显示和不显示把,改属性是改不了的 var txt=window.document.getElementById("cuxiaoPrice");改为:var txt=document.getElementById("cuxiaoPrice"); <script language="JavaScript" type="text/javascript">obj.setAttribute("disabled","disabled"); obj.removeAttribute("disabled"); //...</script> function changeStatus(obj){ var txt=document.getElementById("cuxiaoPrice"); if(obj.checked) { txt.value=""; txt.removeAttribute("disabled"); } else { txt.value=0; txt.setAttribute("disabled","disabled"); }} <html><head><script>function changeStatus(obj) { var txt = document.getElementById("cuxiaoPrice"); if(obj.checked) { txt.value=""; txt.disabled=false; } else { if(!obj.checked){ txt.value=0; } txt.disabled=true; }}</script></head><body> <input type="text" id="cuxiaoPrice" name="cuxiaoPrice"/> <input type="checkbox" id="cuxiaoPrice" name="cuxiaoPrice" onclick="changeStatus(this)"/></body></html> function changeStatus(obj){ var txt=window.document.getElementById("cuxiaoPrice"); if(obj.checked) { txt.value=""; txt.disabled=false; } else { if(!obj.checked){ txt.value="0"; } txt.disabled=true; } //文本框 <s:textfield id="cuxiaoPrice" name="product.promotionPrice" cssClass="txt_height" value="0" cssStyle="width:50px;" onkeyup="value=value.replace(/[^\d.]/g, '')" disabled="true"/>}上面高手说的不对啊~还是不行~ 有什么办法可以行呢??我源代码已经贴上去了~在IE6.0下可以运行,在火狐下点击check一点反应都无,求救!! 另外,把标签换成html标签试试,那段代码我在ff中测试通过,你要看一下<s:textfield 标签被编译转换成html标签后有什么不同的地方 ie和火狐的事件处理机制不一样,你要重document中获取事件对象,然后根据判断对象中的属性来判断是什么浏览器然后处理业务 关于spring security 3.2的启动错误问题 使用HibernateTemplate出现问题 帮忙翻译一下这个错误 Servlet 删除外部数据事例 急急!基于RBAC的权限系统的设计和实现 初学者请教之十一:jsp权限问题 如何在页面加载时实现 奇怪的问题。大家进来帮我看看 一个时间类的JAVABEAN!!! 能够帮忙提供jstl的简单例子以供学习!谢谢 为什么我每次新建了一个Servlet后,我的项目就不能访问了? 大家看一下这个 struts + sql server 2000问题!
function changeStatus(obj)
{
var txt=window.document.getElementById("cuxiaoPrice");
if(obj.checked) {
txt.value="";
txt.disabled=false;
} else {
if(!obj.checked){
txt.value=0;
}
txt.disabled=true;
}
这是JS代码,意思就是如果checkBox被选中,文本框就可以输入,可我在火狐上点checkBox没效果
//txt是文本框,
就是同一种浏览器,比如IE,版本不一样,同样的JS脚本,在IE7中就能用而到IE6上就不行。
有什么办法么?
obj.setAttribute("disabled","disabled");
obj.removeAttribute("disabled");
//...
</script>
var txt=document.getElementById("cuxiaoPrice");
if(obj.checked) {
txt.value="";
txt.removeAttribute("disabled");
}
else {
txt.value=0;
txt.setAttribute("disabled","disabled");
}
}
<html>
<head>
<script>function changeStatus(obj) {
var txt = document.getElementById("cuxiaoPrice");
if(obj.checked) {
txt.value="";
txt.disabled=false;
} else {
if(!obj.checked){
txt.value=0;
}
txt.disabled=true;
}
}
</script>
</head>
<body>
<input type="text" id="cuxiaoPrice" name="cuxiaoPrice"/>
<input type="checkbox" id="cuxiaoPrice" name="cuxiaoPrice" onclick="changeStatus(this)"/>
</body>
</html>
function changeStatus(obj)
{
var txt=window.document.getElementById("cuxiaoPrice");
if(obj.checked) {
txt.value="";
txt.disabled=false;
} else {
if(!obj.checked){
txt.value="0";
}
txt.disabled=true;
}
//文本框
<s:textfield id="cuxiaoPrice" name="product.promotionPrice" cssClass="txt_height" value="0" cssStyle="width:50px;" onkeyup="value=value.replace(/[^\d.]/g, '')" disabled="true"/>
}上面高手说的不对啊~还是不行~