function addTest(){
var n = s.length;
var s1 = "s"+(n+1);
var s2 = "s"+(n+2);
s[n] = s1;
s[n+1] = s2;
document.getElementById("add").innerHTML+="商品品牌:<select id='"+s1+"' name='sp_brand[]'><option></option></select>商品类别:<select id='"+s2+"' name='sp_class[]'><option></option></select>商品货号:<input type='text' name='shop_item[]' style=' width:100px;border-bottom:1px #000000 solid; border-top:none; border-left:none; border-right:none; width:80px;' /> 数量:<input type='text' name='shop_count[]' style=' border-bottom:1px #000000 solid;border-right:none; border-left:none; border-top:none; width:80px;'/> 单价:<input type='text' name='danjia[]' style=' border-bottom:1px #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;'/>";
for(var i=n;i<s.length-1;i++) {
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
}
change(n); //不知道是不是还是0
} function create(){
var _div=document.createElement("div");
document.getElementById('add').appendChild(_div);
var _select=document.createElement("select");
_div.appendChild(document.createTextNode("商品品牌:"));
_div.appendChild(_select);
_select.onchange=fish;
_select.options.add(new Option('请选择','default'));
for(var i in s1){
_select.options.add(new Option(s1[i],i));
}
var _select2=document.createElement("select");
_div.appendChild(document.createTextNode(" 商品类别:"));
_div.appendChild(_select2);
_select2.options.add(new Option('请选择','default'));
var _span=document.createElement("span");
_div.appendChild(_span);
_span.innerHTML="商品货号:<input type='text' name='shop_item[]' style=' width:100px;border-bottom:1px #000000 solid; border-top:none; border-left:none; border-right:none; width:80px;' /> 数量:<input type='text' name='shop_count[]' style=' border-bottom:1px #000000 solid;border-right:none; border-left:none; border-top:none; width:80px;'/> 单价:<input type='text' name='danjia[]' style=' border-bottom:1px #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;'/>";
}<a onClick="create()"><font style="cursor:hand;" color="#0033CC">添加商品</font></a> <br />
为什么在另一个页面上获取不到本页的值?(红色标注的地方的值)
但是蓝色标注的地方却能获取到值,我实在找不出问题来,请大家帮忙。谢谢~~~~~
答完马上给分
var n = s.length;
var s1 = "s"+(n+1);
var s2 = "s"+(n+2);
s[n] = s1;
s[n+1] = s2;
document.getElementById("add").innerHTML+="商品品牌:<select id='"+s1+"' name='sp_brand[]'><option></option></select>商品类别:<select id='"+s2+"' name='sp_class[]'><option></option></select>商品货号:<input type='text' name='shop_item[]' style=' width:100px;border-bottom:1px #000000 solid; border-top:none; border-left:none; border-right:none; width:80px;' /> 数量:<input type='text' name='shop_count[]' style=' border-bottom:1px #000000 solid;border-right:none; border-left:none; border-top:none; width:80px;'/> 单价:<input type='text' name='danjia[]' style=' border-bottom:1px #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;'/>";
for(var i=n;i<s.length-1;i++) {
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
}
change(n); //不知道是不是还是0
} function create(){
var _div=document.createElement("div");
document.getElementById('add').appendChild(_div);
var _select=document.createElement("select");
_div.appendChild(document.createTextNode("商品品牌:"));
_div.appendChild(_select);
_select.onchange=fish;
_select.options.add(new Option('请选择','default'));
for(var i in s1){
_select.options.add(new Option(s1[i],i));
}
var _select2=document.createElement("select");
_div.appendChild(document.createTextNode(" 商品类别:"));
_div.appendChild(_select2);
_select2.options.add(new Option('请选择','default'));
var _span=document.createElement("span");
_div.appendChild(_span);
_span.innerHTML="商品货号:<input type='text' name='shop_item[]' style=' width:100px;border-bottom:1px #000000 solid; border-top:none; border-left:none; border-right:none; width:80px;' /> 数量:<input type='text' name='shop_count[]' style=' border-bottom:1px #000000 solid;border-right:none; border-left:none; border-top:none; width:80px;'/> 单价:<input type='text' name='danjia[]' style=' border-bottom:1px #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;'/>";
}<a onClick="create()"><font style="cursor:hand;" color="#0033CC">添加商品</font></a> <br />
为什么在另一个页面上获取不到本页的值?(红色标注的地方的值)
但是蓝色标注的地方却能获取到值,我实在找不出问题来,请大家帮忙。谢谢~~~~~
答完马上给分
$brand= serialize($_POST["sp_brand"]);
$class=serialize($_POST["sp_class"]);
这个是在另一个页面上获取值的时候,输出是空的。插入到数据库是:N;
在页面上点击它的时候
<a onClick="create()"> <font style="cursor:hand;" color="#0033CC">添加商品 </font> </a> <br /> 就会添加一行:
商品品牌: <select id='"+s1+"' name='sp_brand[]'> <option> </option> </select>商品类别: <select id='"+s2+"' name='sp_class[]'> <option> </option> </select>商品货号: <input type='text' name='shop_item[]' style=' width:100px;border-bottom:1px #000000 solid; border-top:none; border-left:none; border-right:none; width:80px;' /> 数量: <input type='text' name='shop_count[]' style=' border-bottom:1px #000000 solid;border-right:none; border-left:none; border-top:none; width:80px;'/> 单价: <input type='text' name='danjia[]' style=' border-bottom:1px #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;'/>"麻烦大家再看一下谢谢
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function getValue(){ for(i=0;i <document.getElementsByName("brand").length;i++)
{
var ddl = document.getElementsByName("brand")[i];
var aaa=ddl.options[ddl.selectedIndex].value;
alert(aaa);
}
}
function addTest(){
document.getElementById("info").innerHTML+="商品品牌: <select id='s1[i]' name='brand'> <option value=1>test</option> </select>商品类别: <select id='s2[i]' name='class[]'> <option> 3123</option> </select>商品货号: <input type=text name=shop_item[] style='width:100px; border-bottom:1p #000000 solid; border-right:none; border-left:none; border-top:none; width:80px;' /> 数量: <input type=text name=shop_count[] style='width:40px; border-bottom:1px #000000 solid; border-top:none; border-left:none; border_right:none; width:80px;' /> 单价: <input type=text id=test name=danjia style='width:40px; border-bottom:1px #000000 solid; border-top:none; border-left:none; border_right:none; width:80px;' /> <br />";
}
</script>
</HEAD>
<body >
<form id="form1">
<table>
<input type="checkbox" name="myChkbox" />check
<br>
name:<input name="input1" value="">
<br>
<input type="button" value="submit" class="" onclick="getValue();" > <a onclick="addTest();"> <font style="cursor:hand;" color="#0033CC">添加商品 </font> </a> <br >
<div id="info"> </div>
</table>
</form>
</body>
</HTML>