首页 新闻 会员 周边 捐助

动态加载、数据取值、模块更改

0
悬赏园豆:20 [待解决问题]

我用js写了一个简单模块的动态加载,可是在界面取值的时候出现问题,1、首先页面跳转取值,跳转前先将页面数据存进session,带数据跳转回来之后显示在界面中,并将session中数据显示。。2、跳转的界面要动态加载,在js中不好判断。  有没有什么简单的方法能解决?(弹出框系列被否决)   求大神帮帮忙!!!跪谢啊

  1 //增加合作人员
  2         function AddUser() {
  3             
  4             var num = document.getElementById("cooperation_num").value;
  5             var now = (parseInt(num) + 1).toString();
  6             //创建一个table用于放置新添加的内容,并添加到指定的位置
  7             var mytable = document.createElement("table");
  8             var tableid = "table_" + now;
  9             mytable.setAttribute("id", tableid);
 10             document.getElementById("myuser").appendChild(mytable);
 11             //给新建的table添加元素
 12             var name = "name_" + now;
 13             var btn = "Sbtn_" + now;
 14             var telephone = "tel_" + now;
 15             var pact_start_time = "start_" + now;
 16             var pact_end_time = "end_" + now;
 17             var price = "pri_" + now;
 18             if (num == "0") {
 19                 alert(document.getElementById(tableid).innerHTML);
 20                 document.getElementById(tableid).innerHTML = "<tr id='row1_"+now+"'>"
 21                         + "<td id= 'column1_"+now+"'><input type='button' id='"
 22                         + now
 23                         + "' name='"
 24                         + now
 25                         + "' value='清空' onclick='ClearHeZuoRenYuan()' /></td>"
 26                         + "<td id= 'column2_"+now+"'>姓名</td>"
 27                         + "<td id= 'column3_"+now+"'><input type='text' id='"+name+"' name='"+name+"' readonly='true' /><input type='button' id='"+btn+"' name='"+btn+"' value='查询'  /></td>"
 28                         + "<td id= 'column4_"+now+"'>联系方式</td>"
 29                         + "<td id= 'column5_"+now+"'><input type='text' id='"+telephone+"' name='"+telephone+"' readonly='true' /></td></tr>"
 30                         +
 31                         ////document.getElementById(tableid).innerHTML = document.getElementById(tableid).innerHTML + "</tr>"
 32                         "<tr id='row2_"+now+"'><td id= 'column6_"+now+"'></td>"
 33                         + "<td id= 'column7_"+now+"'>时间</td>"
 34                         + "<td id= 'column8_"+now+"'><input type='text' id='"+pact_start_time+"' name='"+pact_start_time+"' readonly='true' />至<input type='text' id='"+pact_end_time+"' name='"+pact_end_time+"' readonly='true' /></td>"
 35                         + "<td id= 'column9_"+now+"'>人员单价</td>"
 36                         + "<td id= 'column10_"+now+"'><input type='text' id='"+price+"' name='"+price+"' readonly='true' /></td>"
 37                         + "</tr>";
 38                 document.getElementById(name).setAttribute("size", "25");
 39                 document.getElementById(btn).setAttribute("onclick", "window.location.href ='../oa/jsp/outsourcing/userinfo/userinfo_manage.jsp'");
 40                 document.getElementById(pact_start_time).setAttribute("size", "10");
 41                 document.getElementById(pact_end_time).setAttribute("size", "10");
 42             } else {
 43                 document.getElementById(tableid).innerHTML = "<tr id='row1_"+now+"'>"
 44                         + "<td id= 'column1_"+now+"'><input type='button' id='"
 45                         + now
 46                         + "' name='"
 47                         + now
 48                         + "' value='删除' onclick='DelUser("
 49                         + now
 50                         + ")' /></td>"
 51                         + "<td id= 'column2_"+now+"'>姓名</td>"
 52                         + "<td id= 'column3_"+now+"'><input type='text' id='"+name+"' name='"+name+"' readonly='true' /><input type='button' id='"+btn+"' name='"+btn+"' value='查询' /></td>"
 53                         + "<td id= 'column4_"+now+"'>联系方式</td>"
 54                         + "<td id= 'column5_"+now+"'><input type='text' id='"+telephone+"' name='"+telephone+"' readonly='true' /></td></tr>"
 55                         +
 56                         ////document.getElementById(tableid).innerHTML = document.getElementById(tableid).innerHTML + "</tr>"
 57                         "<tr id='row2_"+now+"'><td id= 'column6_"+now+"'></td>"
 58                         + "<td id= 'column7_"+now+"'>时间</td>"
 59                         + "<td id= 'column8_"+now+"'><input type='text' id='"+pact_start_time+"' name='"+pact_start_time+"' readonly='true' />至<input type='text' id='"+pact_end_time+"' name='"+pact_end_time+"' readonly='true' /></td>"
 60                         + "<td id= 'column9_"+now+"'>人员单价</td>"
 61                         + "<td id= 'column10_"+now+"'><input type='text' id='"+price+"' name='"+price+"' readonly='true' /></td>"
 62                         + "</tr>";
 63                 document.getElementById(name).setAttribute("size", "25");
 64                 document.getElementById(btn).setAttribute("onclick", "window.location.href ='../oa/jsp/outsourcing/userinfo/userinfo_manage.jsp'");
 65                 document.getElementById(pact_start_time).setAttribute("size", "10");
 66                 document.getElementById(pact_end_time).setAttribute("size", "10");
 67             }
 68             document.getElementById("cooperation_num").value = parseInt(document
 69                     .getElementById("cooperation_num").value) + 1;
 70         }
 71         
 72         
 73         
 74         //清除合作人员信息
 75         function ClearHeZuoRenYuan() {
 76             var num = document.getElementById("cooperation_num").value;
 77             if (confirm("您确定要清除该合作人员吗?")) {
 78                 document.getElementById("name_1").value = "";
 79                 document.getElementById("tel_1").value = "";
 80                 document.getElementById("start_1").value = "";
 81                 document.getElementById("end_1").value = "";
 82                 document.getElementById("pri_1").value = "";
 83                 document.getElementById("cooperation_num").value = "0";
 84             } else {
 85                 return false;
 86             }
 87         }
 88         
 89         
 90         
 91         //删除合作人员
 92         function DelUser(obj) {
 93             if (confirm("您确定要删除该合作人员吗?")) {
 94                 document.getElementById("myuser").removeChild(
 95                         document.getElementById("table_" + obj));
 96                 if (obj != document.getElementById("cooperation_num").value) {
 97                     for ( var i = (parseInt(obj) + 1); i <= parseInt(document
 98                             .getElementById("cooperation_num").value); i++) {
 99                         document.getElementById("table_" + i.toString())
100                                 .setAttribute("id",
101                                         "table_" + (i - 1).toString());
102                         document.getElementById("row1_" + i.toString())
103                                 .setAttribute("id",
104                                         "row1_" + (i - 1).toString());
105                         document.getElementById("column1_" + i.toString())
106                                 .setAttribute("id",
107                                         "column1_" + (i - 1).toString());
108                         document.getElementById(i.toString()).setAttribute(
109                                 "onclick",
110                                 "DelUser(" + (i - 1).toString() + ")");
111                         document.getElementById(i.toString()).setAttribute(
112                                 "name", (i - 1).toString());
113                         document.getElementById(i.toString()).setAttribute(
114                                 "id", (i - 1).toString());
115                         document.getElementById("column2_" + i.toString())
116                                 .setAttribute("id",
117                                         "column2_" + (i - 1).toString());
118                         document.getElementById("column3_" + i.toString())
119                                 .setAttribute("id",
120                                         "column3_" + (i - 1).toString());
121                         document.getElementById("name_" + i.toString())
122                                 .setAttribute("name",
123                                         "name_" + (i - 1).toString());
124                         document.getElementById("name_" + i.toString())
125                                 .setAttribute("id",
126                                         "name_" + (i - 1).toString());
127                         document.getElementById("Sbtn_" + i.toString())
128                                 .setAttribute("name",
129                                         "Sbtn_" + (i - 1).toString());
130                         document.getElementById("Sbtn_" + i.toString())
131                                 .setAttribute("id",
132                                         "Sbtn_" + (i - 1).toString());
133                         document.getElementById("column4_" + i.toString())
134                                 .setAttribute("id",
135                                         "column4_" + (i - 1).toString());
136                         document.getElementById("column5_" + i.toString())
137                                 .setAttribute("id",
138                                         "column5_" + (i - 1).toString());
139                         document.getElementById("tel_" + i.toString())
140                                 .setAttribute("name",
141                                         "tel_" + (i - 1).toString());
142                         document
143                                 .getElementById("tel_" + i.toString())
144                                 .setAttribute("id", "tel_" + (i - 1).toString());
145                         document.getElementById("row2_" + i.toString())
146                                 .setAttribute("id",
147                                         "row2_" + (i - 1).toString());
148                         document.getElementById("column6_" + i.toString())
149                                 .setAttribute("id",
150                                         "column6_" + (i - 1).toString());
151                         document.getElementById("column7_" + i.toString())
152                                 .setAttribute("id",
153                                         "column7_" + (i - 1).toString());
154                         document.getElementById("column8_" + i.toString())
155                                 .setAttribute("id",
156                                         "column8_" + (i - 1).toString());
157                         document.getElementById("start_" + i.toString())
158                                 .setAttribute("name",
159                                         "start_" + (i - 1).toString());
160                         document.getElementById("start_" + i.toString())
161                                 .setAttribute("id",
162                                         "start_" + (i - 1).toString());
163                         document.getElementById("end_" + i.toString())
164                                 .setAttribute("name",
165                                         "end_" + (i - 1).toString());
166                         document
167                                 .getElementById("end_" + i.toString())
168                                 .setAttribute("id", "end_" + (i - 1).toString());
169                         document.getElementById("column9_" + i.toString())
170                                 .setAttribute("id",
171                                         "column9_" + (i - 1).toString());
172                         document.getElementById("column10_" + i.toString())
173                                 .setAttribute("id",
174                                         "column10_" + (i - 1).toString());
175                         document.getElementById("pri_" + i.toString())
176                                 .setAttribute("name",
177                                         "pri_" + (i - 1).toString());
178                         document
179                                 .getElementById("pri_" + i.toString())
180                                 .setAttribute("id", "pri_" + (i - 1).toString());
181                     }
182                 }
183                 document.getElementById("cooperation_num").value = parseInt(document
184                         .getElementById("cooperation_num").value) - 1;
185             } else {
186                 return false;
187             }
188         }
daidongmin的主页 daidongmin | 初学一级 | 园豆:182
提问于:2013-09-17 14:22
< >
分享
所有回答(1)
0

你这个没有后台处理?代码这样看有点混乱,思路好像不是很清楚,如果有后台处理,用ajax提交,可以获得处理后的数据,也可以显示的页面,还可以局部刷新。

wj704 | 园豆:170 (初学一级) | 2013-09-17 19:09

我对ajax不是很会,刚学java,经验技术都不多。大神能写点代码么? 求Q能交流交流

支持(0) 反对(0) daidongmin | 园豆:182 (初学一级) | 2013-09-17 19:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册