如何动态地将文本框设为只读? [英] How can I dynamically make a text box read only?

查看:58
本文介绍了如何动态地将文本框设为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



伙计,


我有七个文本框,其中包含测量值 - 我想要用户输入
它们的值按我列出的顺序排列。


我怎样才能使输入类型=文本名= box2为readonly而

type =文本名称= box1的长度为零?


这是基于内联网的应用程序,我理解所有必须考虑的

争论和要点在这样我的服务器

方PHP不希望数据以某种顺序输入 - 在

另外,我知道有些用户可能想输入数据在

反向,但我更希望这不是这样的。


有人能给我指路吗(我的js正在改善如此粗略的方向
可能就足够了。


谢谢/问候

Randell D.

解决方案

Randell D.写道:

人们,

我有七个文本框,其中包含测量值 - 我希望用户按照我的顺序输入他们的值列出了这些方框。

如何将输入类型= text name = box2设为readonly而
type = text name = box1的长度为零?




box1 ... onchange =" if(this.value){box2reference.readonly = fa lse}">




Mick


Mick White写道:

Randell D.写道:


人们,

我有七个文本框,其中包含测量值 - 我会像用户一样按照我列出
框的顺序输入他们的值。
怎么能因此,我输入type = text name = box2只读
而type = text name = box1的长度为零?

这是基于内联网的应用程序,我理解所有
需要考虑的论点和要点,以便我的
服务器端PHP不希望数据按特定顺序输入 -
另外,我知道有些用户可能想要反向输入数据,但我希望不是这样。



box1 ... onchange =" if(this.value){box2reference .readonly = fa lse}">


Mick




认为应该是'readOnly'' 。 ;-)

这是另一种方法。没时间测试......


< html>

< head>

< title>无标题< / title>

< script type =" text / javascript">


函数inSeq()

{

var els = document.forms [0] .elements,

el,

j = 0,

blank = false;

while(el = els [j ++])

{

blank = blank || (/ ^ \ * *


/ .test(el.value));

if(el = els [j])

el.disabled =空白;

}

}


函数init()

{

var els = document.forms [0] .elements,

el,

j = 0,

blank = false;

while(el = els [j ++])

{

if(/ \b(normal | dependent) \b / .test(el.className))

el.onkeyup = inSeq;

if(/\bdependent\b/.test(el.className) ))

{

blank = blank || / ^ \s *


Folks,

I have seven text boxes which will contain measurements - I would like
the user to input their values in the order that I have listed the boxes.

How can I therefore make an input type=text name=box2 a readonly while
type=text name=box1 has a length of zero?

This is for an intranet based application and I understand all the
arguements and points that one has to consider in such that my server
side PHP does not expect the data to be input in a certain order - in
addition, I know that some users might want to input the data in
reverse, but I would prefer this not to be the case.

Can someone offer me direction (my js is improving so rough direction
would might well be sufficient).

Thanks/Regards
Randell D.

解决方案

Randell D. wrote:


Folks,

I have seven text boxes which will contain measurements - I would like
the user to input their values in the order that I have listed the boxes.

How can I therefore make an input type=text name=box2 a readonly while
type=text name=box1 has a length of zero?

This is for an intranet based application and I understand all the
arguements and points that one has to consider in such that my server
side PHP does not expect the data to be input in a certain order - in
addition, I know that some users might want to input the data in
reverse, but I would prefer this not to be the case.



box1... onchange="if(this.value){box2reference.readonly=fa lse}">

etc.
Mick


Mick White wrote:

Randell D. wrote:


Folks,

I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes.
How can I therefore make an input type=text name=box2 a readonly while type=text name=box1 has a length of zero?

This is for an intranet based application and I understand all the
arguements and points that one has to consider in such that my server side PHP does not expect the data to be input in a certain order - in addition, I know that some users might want to input the data in
reverse, but I would prefer this not to be the case.



box1... onchange="if(this.value){box2reference.readonly=fa lse}">

etc.
Mick



Think that should be ''readOnly''. ;-)
Here''s another approach. No time to test so...

<html>
<head>
<title>untitled</title>
<script type="text/javascript">

function inSeq()
{
var els = document.forms[0].elements,
el,
j = 0,
blank = false;
while (el = els[j++])
{
blank = blank || (/^\s*


/.test(el.value));
if (el = els[j])
el.disabled = blank;
}
}

function init()
{
var els = document.forms[0].elements,
el,
j = 0,
blank = false;
while (el = els[j++])
{
if (/\b(normal|dependent)\b/.test(el.className))
el.onkeyup = inSeq;
if (/\bdependent\b/.test(el.className))
{
blank = blank || /^\s*


这篇关于如何动态地将文本框设为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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