81,094
社区成员
发帖
与我相关
我的任务
分享
<input type="hidden">
进行提交,但问题是每次提交时原来的[code=HTML><span>属 性:</span></td><td id="attContext"><input type="text" name="attrib_name">value<input type="text" name="attrib_value">
不提交呢!!!<input type="text" name="attrib_name">value<input type="text" name="attrib_value">
都是List的一个元素的属性<form method="get" action="insertSortAction.action">
<table>
<tr><td>新 建:</td>
<td><select id="isLeaf" name="sort.isLeaf" onchange="showlist()">
<option value="false" selected="selected">分类</option>
<option value="true">商品</option>
</select>
</td></tr>
<!-- 类别
-->
<tr><td>名 称:</td><td><input type="text" name="sort.name"></td></tr>
<tr><td>父结点</td><td><input type="text" name="parent.name"></td></tr>
<tr id="att"><td><span>属 性:</span></td><td id="attContext">
<div>name<input type="text" name="attrib_name">value<input type="text" name="attrib_value">
<input type="hidden" name=attrib value="aaaa">
<input type="button" value="增加" onclick="addAttrib()" ></div>
</td></tr>
<input type="button" onclick="change()">
<tr><td><input type="submit" value="提交" onclick="change()"></td></tr>
</table>
</form>
function showlist(){
var isLeaf=document.getElementById("isLeaf");
if(isLeaf.value=="true"){
$("#att").show();
}
if(isLeaf.value=="false"){
$("#att").hide();
}
}
function addAttrib(){
$("#attContext").append('<div>name<input type="text" name="attrib_name">value<input type="text" name="attrib_value"><input type="button" value="���" onclick="addAttrib()" ></div>');
}
function change(){
var attrib_name=$("input[name='attrib_name']").val();
var attrib_value=$("input[name='attrib_value']").val();
var attrib=attrib_name+','+attrib_value;
attrib=$("input[name='attrib']").attr("value",attrib);
alert($("input[name='attrib']").val());
}
<input type="text" name="name[]">
呵呵,继续研究