最近US那边问了个有关页面上button控制的问题。 如下:
引用
当某几个字段的值都不为空的时候显示button, 只要有一个部位空则隐藏之。
于是乎便有了如下代码:
<div style="height:0px;width:100%;">
<script language="javascript">
var targetElmt0 = document.getElementById('A0.R0.Estimated Close Date');
var targetElmt1 = document.getElementById('A0.R0.Lead Source');
var targetElmt2 = document.getElementById('A0.R0.Campaign Name');
var targetElmt3 = document.getElementById('A0.R0.Industry Name - Translation');
var targetElmt4 = document.getElementById('A0.R0.Annual Revenue');
var targetValue0, targetValue1, targetValue2, targetValue3, targetValue4;
if(targetElmt0 != null)
targetValue0 = targetElmt0.innerHTML;
if(targetElmt1 != null)
targetValue1 = targetElmt1.innerHTML;
if(targetElmt2 != null)
targetValue2 = targetElmt2.innerHTML;
if(targetElmt3 != null)
targetValue3 = targetElmt3.innerHTML;
if(targetElmt4 != null)
targetValue4 = targetElmt4.innerHTML;
if((targetValue0 == null || targetValue0 == ' ') || (targetValue1 == null || targetValue1 == ' ') ||
(targetValue2 == null || targetValue2 == ' ') || (targetValue3 == null || targetValue3 == ' ') ||
(targetValue4 == null || targetValue4 == ' '))
document.getElementById('BTN_TB_LeadDetailForm_ConvertLead').style.display = "none";
</script>
</div>
US 看了说 "Very cool! It does work!", 但是他想在用户填完所有字段后又把那个button显示出来. 于是他的idea是加个web link 放到页面上, 默认是隐藏的, 然后想通过某中方法去判断是否该显示这个web link, 在然后用户可以点这个web link来刷新整个页面, 这是那个button就可以点了。。。。。。oh, my god!!!!!!!
有这么麻烦么??? 是不是一个timer就搞定了??? 有模有???
<div style="height:0px;width:100%;">
<script language="javascript">
var allFilled = checkIfAllFilled();
if(!allFilled) hide();
var intervalID = setInterval("show()", 1000);
function checkIfAllFilled() {
var targetElmt0 = document.getElementById('A0.R0.Estimated Close Date');
var targetElmt1 = document.getElementById('A0.R0.Lead Source');
var targetElmt2 = document.getElementById('A0.R0.Campaign Name');
var targetElmt3 = document.getElementById('A0.R0.Industry Name - Translation');
var targetElmt4 = document.getElementById('A0.R0.Annual Revenue');
var targetValue0, targetValue1, targetValue2, targetValue3, targetValue4;
if(targetElmt0 != null)
targetValue0 = targetElmt0.innerHTML;
if(targetElmt1 != null)
targetValue1 = targetElmt1.innerHTML;
if(targetElmt2 != null)
targetValue2 = targetElmt2.innerHTML;
if(targetElmt3 != null)
targetValue3 = targetElmt3.innerHTML;
if(targetElmt4 != null)
targetValue4 = targetElmt4.innerHTML;
if((targetValue0 == null || targetValue0 == ' ') || (targetValue1 == null || targetValue1 == ' ') ||
(targetValue2 == null || targetValue2 == ' ') || (targetValue3 == null || targetValue3 == ' ') ||
(targetValue4 == null || targetValue4 == ' '))
return false;
return true;
}
function hide() {
document.getElementById('BTN_TB_LeadDetailForm_ConvertLead').style.display = "none";
}
function show() {
if(checkIfAllFilled()) {
document.getElementById('BTN_TB_LeadDetailForm_ConvertLead').style.display = "block";
clearInterval(intervalID);
}
}
</script>
</div>
。。。。。。。。。 我是分割点 。。。。。。。。。。。。
老外就是这样, 一次不把需求说清楚, 本来自己也是想到了但怕画蛇添足所以就没加:
如果所有字段都填好的, 但现在null out任意一个, 则需要隐藏那个button.
简单是简单, 不过来回折腾了好几封邮件。。。恩就把show()方法改一下就好了
function show() {
if(checkIfAllFilled()) {
document.getElementById('BTN_TB_LeadDetailForm_ConvertLead').style.display = "block";
} else {
document.getElementById('BTN_TB_LeadDetailForm_ConvertLead').style.display = "none";
}
}
分享到:
相关推荐
用JS实现的计时程序,起点为当前时间,界面美观大方
计时器简单轻量级的 javascript 计时器开始在需要的地方包含 timer.min.js。 创建一个定时器实例:timer = new Timer ( < callback> , < instance> ); 调用 timer.start(duration) 函数。 每隔几秒,就会调用 ...
jquery timer, -.1.2.js
最近开始接触flex,比起javascript,感觉as3的Timer类甚是强大。而javascript只有裸体的setTimeout,setInternval。要实现稍微复杂一点的功能,稍微没有底子的程序员就会把代码写的很乱。
jquery.timer.js 实现的动态显示时间.
tmer一个node.js的简单timer
主要介绍了在JavaScript中如何使用timer,并给出各种测试case的例子,需要的朋友可以参考下
jquer开发时间格式化资源,网络收集,收集于网络资源
在ria设计中,js中使用settimeout,无法立刻使线程退出,所以写个timer,可以模拟到Timer的start和stop, 例子1: var timer=new Timer(); var timerNum=0 timer.callback=function(){ timerNum++; } timer.start()...
一个简单的Javascript计时器 const timer = new Timer(); //启动计时器timer.start(); //暂停计时器timer.pause(); //停止计时器timer.stop(); {const timer = new Timer(); timer.start(); timer....
http-timer:对HTTP请求进行计时
#JSTimer 一个简单JavaScript计时器。 参见patricktraeger.info/projects/timer上的演示 #执照 麻省理工学院执照
在JavaScript中用法timer示例_.docx
计时器时钟TimerClock是易于使用的倒数/秒表/时钟应用程序特征倒数计时时间倒数倒计时器跑表钟依赖项/库TimerClock运行在并使用下列项目: countdown.js timer.js 引导程序 jQuery的执照根据MIT许可证(MIT)许可。...
关于Ajax的Timer组件的应用,不刷新页面,时间显示走动,省去了繁琐了JS代码,实现不刷新页面时间的变化。格式为(2011年08月16日 星期二 13:42:20 PM),附带效果图。
安装Npm npm install moment-timer凉亭bower install moment-timerCDN [removed][removed]浏览器[removed][removed]在浏览器中使用此插件时,请确保首先在页面上包含moment.js。属性(布尔)开始new moment .
self-timer.js概述self-timer.js是用于javascript的轻量级回调运行器库。self-timer.js的名称源自“ self-timer”,它是相机上的设备。 您可以在要执行时的时间运行回调,就像self-timer一样。 例如,如果今天是工作...
p5.timer.js 由斯科特·基尔达尔(Scott Kildall) 夏娜(Alina Xia)修改 概述 这是p5.js的类,它将用作计时器。 它封装了millis()函数和各种您可以用来执行异步计时操作的变量。 将其添加到index.html 使用此...