这个问题最好到Web板块的js论坛去问
解决方案 »
- 我要做一个购物网站,用什么技术好呢?
- struts整合了spring,可以配置多个controller吗?
- apache+tomcat整合以后,为什么apache访问jsp页面时,出现的是该jsp页面的源代码?
- 求解决禁止一个用户在多台机子登录的方案?
- EJB入门级问题, 有经验的帮我看一下,谢谢
- 有做管理软件的吗?
- 建立聊天程序 UDP server 需要用到线程么?如果需要,怎么用?
- 请问有没有关于怎么在j2ee中开发xml的资料,最好能详细一点!
- java corba连接T2000网管
- ssh架构错误,请大家帮忙看看怎么回事?
- struts加tils应用,部署在jboss上,出现乱码?从数据库上查询出来的中文可以正常显示。
- 如何先让标签体内的内容执行
document.getElementByID("idName").innerHTML="<input type="text" name="txt" />";
document.getElementByID("idName").innerHTML="<input type="text" name="txt" />";
---------------------------------------
就是这个思想,还有其他的方法,也可以达到这个效果,不过,思想是一样的。具体方法:参照 DOM 的操作。
1.先做一个数据对象来取循环生成文本框的值:GetLoopTextValue,写个数组来取,具体的就不用写出来了吧
2.在循环生成文本框时候,<html:text property="GetLoopTextValue.getText[1]"> 生成时候注意getText[i]中的i变量就行了
3.然后在formbean中直接取
private GetLoopTextValue value = new GetLoopTextValue(); public CityStateZip getCityStateZip() {
return value ;
}
public void setCityStateZip(CityStateZip value ) {
this.value = value ;
}
{
var row =TableID.insertRow(TableID.rows.length);
var col = row.insertCell(0);
col.innerHTML = "<input type='checkbox'id='chk' name='chk' width='100%'>";
for(var i=1;i<=2;i++)
{
col = row.insertCell(i);
col.innerText="";
}
col = row.insertCell(3);
col.innerText="1";
col = row.insertCell(4);//检测部门
col.innerHTML=show_deptlist.innerHTML;//把一个层加进来
col = row.insertCell(5);//强检
col.innerHTML="<INPUT type='checkbox' name='ChkQJ'>";
col = row.insertCell(6);
col.innerText="";
}<TABLE id="RecordTable" style="BORDER-COLLAPSE: collapse" onclick="EditRow(RecordTable)" borderColor="#c0c0c0" height="22" cellSpacing="1" cellPadding="2" width="794" border="1">
<TR>
<TD vAlign="middle" align="center" width="69" bgColor="#e1e1e1" height="10">
选择
</TD>
<TD vAlign="middle" align="center" width="150" bgColor="#e1e1e1" height="10">
器具ID
</TD>
<TD vAlign="middle" align="center" width="400" bgColor="#e1e1e1" height="10">
器具名称
</TD>
<TD vAlign="middle" align="center" width="120" bgColor="#e1e1e1" height="10">
数量
</TD>
<TD vAlign="middle" align="center" width="300" bgColor="#e1e1e1" height="10">
检测部门
</TD>
<TD vAlign="middle" align="center" width="100" bgColor="#e1e1e1" height="10">
强检
</TD>
<TD vAlign="middle" align="center" width="280" bgColor="#e1e1e1" height="10">
承诺日期
</TD>
</TR>
</TABLE>
table后面的id不能省保存之前先通过循环把值取出来,放到隐藏字段部分代码如下: for(var i=1;i<TableID.rows.length;i++)
{
var row=TableID.rows[i];
ReceiveForm.TxtInstrumentIdArray.value+=row.cells[1].innerText;
ReceiveForm.TxtInstrumentNameArray.value+=row.cells[2].innerText;
ReceiveForm.TxtNumsArray.value +=row.cells[3].innerText;
ReceiveForm.TxtCheckDepartmentIdArray.value +=row.cells[4].getElementsByTagName("SELECT")[0].value;
ReceiveForm.TxtQjArray.value +=row.cells[5].getElementsByTagName("INPUT")[0].checked;
ReceiveForm.TxtDateArray.value +=row.cells[6].innerText;
if (i<TableID.rows.length-1)
{
ReceiveForm.TxtInstrumentIdArray.value+=",";
ReceiveForm.TxtInstrumentNameArray.value+=",";
ReceiveForm.TxtNumsArray.value +=",";
ReceiveForm.TxtCheckDepartmentIdArray.value +=",";
ReceiveForm.TxtQjArray.value +=",";
ReceiveForm.TxtDateArray.value +=",";
}
}
服务端用split函数分解隐藏字段,然后通过循环插入值
我毕业设计用struts spring hibernate 实现的,这一块JS脚本花的时间是最多的
楼主是问如何动态添加Struts标签吧。这个基本上不能。