从文本文件中读取,然后决定是要禁用还是启用php中的按钮
Read from a text file and then decide wether we want to disable or enable a button in php
$filename ="E:''Serialportread''boxcheck.txt";
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
fclose($handle);
if($data=="CLOSED")
{
echo'<td><button id="read" class="bott2" style="margin-top:18px;">Read</button></td><td>';
}
else{
echo'<td><button id="read" class="bott2" style="margin-top:18px;" disabled="disabled">Read</button></td><td>';
}
这发生在点击之前。
下面的代码是点击功能定义的:
$('#read').click(function(e){
var fso1, ForReading;
ForReading = 1;var status;
fso1 = new ActiveXObject("Scripting.FileSystemObject");
file = fso1.OpenTextFile("E:''Serialportread''boxcheck.txt", ForReading, false, -2);
status = file.ReadLine();
file.Close();
alert(status);
if(status=='CLOSED')
{
alert('ysess');
$.fn.a();
e.preventDefault();
}
else{
alert('error')
$('#read').html('');
str='<diasabled="disabled">';
$('#read').append(str);
alert('yes');
}
});
两个代码都不起作用。我也尝试了另一个代码,但它一次又一次地刷新我的页面,这是我不想要的。
中存在语法错误
str='<diasabled="disabled">';
diA军刀
你应该尽量不要干扰HTML,而是使用样式:
if(status=='CLOSED')
{
alert('ysess');
var cb = $("#read");
cb.removeAttribute("disabled");
removeClass(cb, "button-disabled");
}
else
{
alert('error')
var cb = $('#read');
// visually change the button - otherwise it does not look as disabled
addClass(cb, "button-disabled");
cb.setAttribute("disabled","");
alert('yes');
}
相关文章:
- 如何根据需要在php中启用和禁用特定日期
- .post javascript with PHP 以启用 select 语句返回
- 根据同一页面上的 if 条件禁用/启用 PHP 中的表单值
- 如何使用PHP在浏览器中检查Javascript是否启用
- 在 php/javascript 中单击另一个页面中的按钮时需要启用按钮
- 如何为此启用就地编辑 code.so 我需要在 Update.php 文件中更新该值
- 使用javascript和php启用和禁用按钮
- 如果启用了javascript,则阻止php执行
- JavaScript启用按钮在php中不起作用
- JavaScript按钮启用和禁用与PHP
- 根据php中附带的复选框更改生成的文本框可见性或启用状态
- 是否有一种方法来检查是否在php或javascript中启用了流水线
- 当页面空闲时,我如何在php中启用或禁用javascript
- 是否可以使用PHP在web浏览器中启用/禁用JavaScript ?
- 我可以从PHP中查看是否启用了Java
- 检查Safari是否阻止“来自第三方和广告商”的cookie;使用javascript/php启用
- 如果javascript未启用,则停止加载PHP页面
- 如何使用PHP在webix中启用延迟加载
- 从文本文件中读取,然后决定是要禁用还是启用php中的按钮
- 使用JS或PHP检测Firefox中启用的扩展