通过点击切换文本框内容的脚本示例

    定义一个字符串为内容的数组,每一行的多个文本框为一组,要求点击切换内容,且内容不重复.

 

代码
 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 2 <html>
 3  <head>
 4   <title> New Document </title>
 5   <script>
 6 var lastRowIndex=0;//上次变化行号
 7 var opt;
 8 var idPrefix="ToToChoiceOrder";
 9 function changeOrder(r,c)
10 {
11   var optTmp=new Array();
12   opt=['A','B','C','D'];
13   if(1==c){
14     //如果点击的是首,要清空次末,记录首现在的值
15     document.getElementById(idPrefix+r+eval(c+1)).value="";
16     document.getElementById(idPrefix+r+eval(c+2)).value="";
17     optTmp.unshift(document.getElementById(idPrefix+r+c).value);
18   }
19   else if(2==c){
20     //如果点击的是次,要清空末,记录首次现在的值
21     document.getElementById(idPrefix+r+eval(c+1)).value="";
22     optTmp.unshift(document.getElementById(idPrefix+r+eval(c-1)).value);
23     optTmp.unshift(document.getElementById(idPrefix+r+c).value);
24   }
25   else if(3==c){
26     //如果点击的是末,记录首次末现在的值
27     optTmp.unshift(document.getElementById(idPrefix+r+eval(c-2)).value);
28     optTmp.unshift(document.getElementById(idPrefix+r+eval(c-1)).value);
29       optTmp.unshift(document.getElementById(idPrefix+r+c).value);
30   }
31   //alert("现在已有的选项是"+optTmp); 
32   tmp=optTmp.join();
33   count=0;
34   len=opt.length;
35   while(count<len){
36     //alert("当前循环检查的值是"+opt[0]);
37     if(-1 != tmp.indexOf(opt[0])){
38       //alert("开头的值"+opt[0]+"已被选择");
39       opt.shift();
40       //alert("去掉后的选项有"+opt);
41       if(optTmp.length==count) break;
42       //opt.splice(i,1);
43     }else{
44       t=opt.shift();
45       //alert("去掉开头的值"+t);
46       opt.push(t);
47       //alert("加到尾部的值"+t);
48     }
49     //alert(opt);
50     count++;
51   }
52   document.getElementById(idPrefix+r+c).value= opt[0]?opt[0]:'';
53 }
54  </script>
55  </head>
56  <body>
57   <table width="120px" border="0" align="center" cellpadding="0" cellspacing="1" class="SmallFont">
58   <tr>
59     <td bgcolor="#C0D2EB"><div align="center" class="STYLE15">顺序</div></td>
60     <td bgcolor="#C0D2EB"><div align="center" class="STYLE15"></div></td>
61     <td bgcolor="#C0D2EB"><div align="center" class="STYLE15"></div></td>
62     <td bgcolor="#C0D2EB"><div align="center" class="STYLE15"></div></td>
63    
64   </tr>
65   <tr  align="center">
66     <td width="20" height="25"><div align="center" class="matchno">1</div></td>
67      <td width="19"><div align="center">
68     <input type="text" id="ToToChoiceOrder11" name="ToToChoiceOrder11" readonly="readonly"  size="1" value="3" class="FSInput1" onclick="changeOrder(1,1)" />
69     </div></td>
70     <td width="19"><div align="center">
71       <input type="text" id="ToToChoiceOrder12" name="ToToChoiceOrder12" readonly="readonly"  size="1" value="" class="FSInput1" onclick="changeOrder(1,2)" />
72     </div></td>
73     <td width="19"><div align="center">
74       <input type="text" id="ToToChoiceOrder13" name="ToToChoiceOrder13" readonly="readonly"  size="1" value="" class="FSInput1" onclick="changeOrder(1,3)" />
75     </div></td>
76   </tr>
77   <tr  align="center">
78     <td width="20" height="25"><div align="center" class="matchno">2</div></td>
79    
80     <td width="19"><div align="center">
81     <input type="text" id="ToToChoiceOrder21" name="ToToChoiceOrder21" readonly="readonly"  size="1" value="3" class="FSInput1" onclick="changeOrder(2,1)" />
82     </div></td>
83     <td width="19"><div align="center">
84       <input type="text" id="ToToChoiceOrder22" name="ToToChoiceOrder22" readonly="readonly"  size="1" value="" class="FSInput1" onclick="changeOrder(2,2)" />
85     </div></td>
86     <td width="19"><div align="center">
87       <input type="text" id="ToToChoiceOrder23" name="ToToChoiceOrder23" readonly="readonly"  size="1" value="" class="FSInput1" onclick="changeOrder(2,3)" />
88     </div></td>
89   </tr>
90   </table>
91  </body>
92 </html>
93 

 

转载于:https://www.cnblogs.com/BeanHsiang/archive/2009/11/29/1613137.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/262243.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

qmenu只在鼠标单击时消失_两种方法解决win10电脑无法使用无线鼠标问题

使用有线鼠标时用户们是否也都会被那条线控制住&#xff0c;有时需要大范围移动时并不行&#xff0c;现在很多用户都会选择使用无线鼠标&#xff0c;因为可以随意移动使用更加方便。但是在使用中也有用户遇到了麻烦&#xff0c;使用win10连接鼠标后无法使用&#xff0c;这是要怎…

蓝桥杯 带分数

来一个全排列&#xff0c;然后枚举跟/的位置&#xff0c;时间复杂度大概是&#xff0c;9。*28历届试题 带分数 时间限制&#xff1a;1.0s 内存限制&#xff1a;256.0MB问题描写叙述100 能够表示为带分数的形式&#xff1a;100 3 69258 / 714。 还能够表示为&#xff1a;10…

java tempfile read_Java 文件操作

Java 实例 - 文件写入以下实例演示了使用 write() 方法向文件写入内容&#xff1a;import java.io.*;public class WriteDemo {public static void main(String[] args) {try {BufferedWriter out new BufferedWriter(new FileWriter("runoob.txt"));out.write(&quo…

设置图片圆角 或者圆形

1.//用画图的方式设置圆角 mImageView.image[UIImage imageNamed:"bg1.png"]; mImageView.frameCGRectMake(center.x-radius, center.y-radius, 2*radius, 2*radius); mImageView.layer.cornerRadiusradius;//设置圆角半径 mImageView.layer.masksToBoundsYES; [mIma…

“Word.Tables”并不包含“Item”的定义的解决办法

C#调用WORD时出错如下&#xff1a; object missingValue Type.Missing;object location strInfo.Length; //如果location超过已有字符的长度将会出错。一定要比"明细表"串多一个字符 Word.Range rng2 wordDoc.Range(ref location,…

线程的几个状态

Runnable&#xff1a;一般指该线程正在执行状态中&#xff0c;该线程占用了资源&#xff0c;正在处理某个请求&#xff0c;例如有可能在对某个文件操作&#xff0c;有可能进行数据类型等转换。Waiting on condition&#xff1a;等待资源&#xff0c;或等待某个条件的发生。具体…

c++ 数组的输入遇到特定字符停止输入_滑动窗口思维--挑战“无重复字符的最长子串”

文章来源&#xff1a; 饭饭的Python学习之路作者&#xff1a; 一粒米饭今天要挑战的是“无重复字符的最长子串”。难度&#xff1a;中等题目描述&#xff1a;给定一个字符串&#xff0c;请你找出其中不含有重复字符的 最长子串 的长度。示例1:输入: "abcabcbb"输出: …

Effective C++ 读书笔记(八)

8 定制new和delete 条款49&#xff1a;了解new-handler的行为 new_handler set_new_handler (new_handler new_p) throw(); Sets new_p as the new handler function, the old one is returned. operator new抛出异常以反映一个未获满足的内存需求之前&#xff0c;它会先调…

12.8 早晨我一直在假笑,为了骗自己

最近不知道为啥&#xff0c;总是凌晨醒来&#xff0c;然后睡不着了就&#xff0c;再然后就会控制不住的想一些事情一些人一些工作。之前听别人这样说的时候&#xff0c;都觉得很奇怪,现在轮到自己了 大概是因为压力过大&#xff1f;精神已经超级紧绷啦&#xff1f;还是因为。。…

Restful HMAC认证

我们在设计REST(Representational State Transfer)风格的Web service API,有一个问题经常要考虑&#xff0c;就是如何设计用户认证的体系(Authentication). 比较传统的做法是首先有一个登陆的API&#xff0c;然后服务器返回一个session ID,后续的操作客户端都必须带上这个sess…

docker 打包_Springboot2.0学习11 使用maven插件打包docker部署应用

一、本文目标使用Maven插件构建SpringBoot应用的docker镜像镜像推送至Docker Registry启动容器本文开发环境 &#xff1a;jdk1.8mavenideaSpringBoot2.2本文使用 com.spotify 的 docker-maven-plugin插件执行docker命令。据说官方不再推荐使用该插件&#xff0c;而是使用 docke…

java一个源文件供一个程序_java02 Java源文件范例提供了一个布局合理的Java程序范例 - 下载 - 搜珍网...

新建文件夹/day04/CheckString.class新建文件夹/day04/CheckString.java新建文件夹/day04/EqualsTest.class新建文件夹/day04/EqualsTest.java新建文件夹/day04/ReferencesTest.class新建文件夹/day04/ReferencesTest.java新建文件夹/day04/SetPoints.class新建文件夹/day04/Se…

[转帖]Mootools源码分析-49 -- Asset

原帖地址&#xff1a;http://space.flash8.net/space/?uid-18713-action-viewspace-itemid-410355 原作者&#xff1a;我佛山人 代码 //脚本,样式和图片的资源加载varAsset newHash({ //脚本资源的加载javascrīpt: function(source, properties) { //合并属性项…

桌面壁纸大全:50套高清 Mac 桌面壁纸背景【下篇】

这篇文章收集一组非常精美的 Mac 高清桌面壁纸分享给大家&#xff0c;这些都是仔细挑选的完美图片。挑选一张自己最喜欢的 Mac 高清桌面壁纸给你的电脑换上&#xff0c;让你的电脑看起来与众不同。 您可能还喜欢 分享18套精美的苹果风格免费图标素材10套精美的免费网站后台管理…

SpeedyCloud研发总监李孟:不要让底层细节被上层打败

随着互联网的发展&#xff0c;对于现代企业来说&#xff0c;DNS与CDN服务的作用正变得愈发重要&#xff0c;网络访问速度决定了前端客户体验&#xff0c;同时也影响着内部业务系统的运行。SpeedyCloud作为一家新晋IaaS云服务供应商&#xff0c;在DNS与CDN方面同样拥有丰富的实践…

springboot 关闭懒加载_SpringBoot新手入门篇

SpringBoot是干哈的介绍&#xff1a;springboot是由Pivotal团队提供的全新框架。spring的出现是为了解决企业级开发应用的复杂性&#xff0c;spring的通过注册bean的方式来管理类&#xff0c;但是随着业务的增加&#xff0c;使用xml配置bean的方式也显得相当繁琐&#xff0c;所…

java.security.key jar_异常: java.security.InvalidKeyException: Illegal key size

今天在做接口测试的时候遇到个异常&#xff1a;java.security.InvalidKeyException: Illegal key size。SecretKeySpec secretKeySpec new SecretKeySpec(aesKey, "AES");Cipher cipher Cipher.getInstance("AES/CTR/NoPadding");IvParameterSpec ips c…

CACTI 0.87e 安装

Cacti 是一个使用 RRDtool 引擎的基于网页的 PHP/MySql 图形解决方案。 Classically, 它可以使用 SNMP 来绘制网络带宽。但事实上&#xff0c;也可以通过 snmp&#xff0c;shell 或者 perl 脚本来绘制很多不同的图形。在 屏幕截图 部分&#xff0c;你可以浏览使用 Cacti 可以绘…

NodeManager启动流程与服务

本文介绍了NodeManager的启动流程与服务. NodeManager主流程 在main方法中new一个 NodeManager, 然后初始化并启动. 这里主要看initAndStartNodeManager方法. 首先是增加一个shutDownHook, 即CompositeServiceShutdownHook, 它的目的是为了在NodeManager crash的时候停止compos…

Unity3D的断点调试功能

&#xfeff;&#xfeff;这篇文章介绍的调试工具是Unity自带的MonoDevelop, 假设要用VS&#xff0c;须要下载unityvs http://unityvs.com/. http://liweizhaolili.blog.163.com/blog/static/162307442013214485190/ 断点调试功能可谓是程序猿必备的功能了。Unity3D支持编写js…