此贴由http://topic.csdn.net/u/20090805/08/5d258c1d-6976-4924-b5fc-409ec2365269.html延伸而来由于之前的贴子问题一直没有解决,现在只能用以上代码帮attrib.name和attrib.value进行拼装并用<input type="hidden">进行提交,但问题是每次提交时原来的[code=HTML><span>属 性:</span></td><td id="attContext">
<div>name<input type="text" name="attrib_name">value<input type="text" name="attrib_value">
[/code]也都一起提交了,那怎么让<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());
}
<div>name<input type="text" name="attrib_name">value<input type="text" name="attrib_value">
[/code]也都一起提交了,那怎么让<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());
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货