确定输入框属性 [英] Determine Input Box Property

查看:55
本文介绍了确定输入框属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,只有当我的输入框不是

禁用时才能运行。有人能告诉我脚本是否有问题吗?

" disabled"正确使用的属性?


函数TextChanged(i){

if(!document.ScheduleForm [" txtGrossPayroll" + i] .disabled){

document.ScheduleForm.txtRecordStatus.value ="所做的改变;记录不是

已保存。" ;;

document.ScheduleForm.txtRecordStatus.style.color ="#FF0000";

}

}

谢谢,

CR Junk

解决方案

< BLOCKQUOTE>" crjunk"写了

我有一个脚本,我只想在我的输入框没有被禁用时运行。有人能告诉我脚本是否有问题吗?
禁用正确使用的属性?

函数TextChanged(i){
if(!document.ScheduleForm [" txtGrossPayroll" + i] .disabled){
document.ScheduleForm。 txtRecordStatus.value ="所做的更改;记录不是
已保存。" ;;
document.ScheduleForm.txtRecordStatus.style.color ="#FF0000" ;;
}
}




对我来说很好看。不满意它的运行方式?只是挑剔,但是对于txtRecordStatus元素的两次查找可以通过将其存储在临时变量中来有效地处理更多




function TextChanged(i){

var sf = document.forms.ScheduleForm.elements;

if(!sf [" txtGrossPayroll" + i] .disabled) {

var rs = sf.txtRecordStatus;

rs.value ="所做的改变;记录未保存。;

rs.style.color ="#FF0000" ;;

}

}


hth

ivo



ivo写道

只是挑剔,但通过将它存储在临时变量中可以更有效地处理对txtRecordStatus元素的两次查找




感谢您使用临时变量的信息。 br />

我发现了一个我用过的错误。而不是禁用,我将输入

设置为只读 - 因此公式应为:

if(!document.ScheduleForm [" txtGr * ossPayroll" + i] .readonly)


使用readonly会有什么不同吗?


谢谢,

CR Junk


" crjunk"写了

而不是禁用,我将输入
设置为只读 - 因此公式应该是:
if(!document.ScheduleForm [" txtGr * ossPayroll" + i] ] .readonly)

使用readonly会有什么不同吗?




完全没有,但请注意DOM属性区分大小写,

" readOnly"有一个大写O.


一个链接(请注意换行):
http://msdn.microsoft.com/workshop/a...erties/readonl

y_1。 asp b / b

ivo


I have a script that I want to run only when my input box IS NOT
disabled. Can someone tell me if something is wrong with my script? Is
"disabled" the correct property to use?

function TextChanged(i){
if (!document.ScheduleForm["txtGrossPayroll" + i].disabled) {
document.ScheduleForm.txtRecordStatus.value = "Changes Made; Record Not
Saved.";
document.ScheduleForm.txtRecordStatus.style.color = "#FF0000";
}
}
Thanks,
CR Junk

解决方案

"crjunk" wrote

I have a script that I want to run only when my input box IS NOT
disabled. Can someone tell me if something is wrong with my script? Is
"disabled" the correct property to use?

function TextChanged(i){
if (!document.ScheduleForm["txtGrossPayroll" + i].disabled) {
document.ScheduleForm.txtRecordStatus.value = "Changes Made; Record Not
Saved.";
document.ScheduleForm.txtRecordStatus.style.color = "#FF0000";
}
}



Looks good to me. Not happy with how it runs? Just nitpicking, but the
two lookups into the txtRecordStatus element could be handled more
efficiently by storing it in a temporary variable:

function TextChanged(i){
var sf = document.forms.ScheduleForm.elements;
if ( !sf["txtGrossPayroll" + i].disabled ) {
var rs = sf.txtRecordStatus;
rs.value = "Changes Made; Record Not Saved.";
rs.style.color = "#FF0000";
}
}

hth
ivo



ivo wrote

Just nitpicking, but the two lookups into the txtRecordStatus element could be handled more efficiently by storing it in a temporary variable



Thanks for the information on using a temporary variable.

I found a mistake that I used. Instead of disabled, I have the input
set as readonly - therefore the formula should be :
if (!document.ScheduleForm["txtGr*ossPayroll" + i].readonly)

Does using readonly make any difference?

Thanks,
CR Junk


"crjunk" wrote

Instead of disabled, I have the input
set as readonly - therefore the formula should be :
if (!document.ScheduleForm["txtGr*ossPayroll" + i].readonly)

Does using readonly make any difference?



None at all, but note that the DOM properties are case-sensitive and
"readOnly" features a capital O.

A link (watch for wrap):
http://msdn.microsoft.com/workshop/a...erties/readonl
y_1.asp

chrs
ivo


这篇关于确定输入框属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆