中易网

php 接收左右选择框的值

答案:2  悬赏:40  
解决时间 2021-04-28 07:08
  • 提问者网友:巴黎塔下许过得承诺
  • 2021-04-27 15:17
php文件
<?php
header("Content-type: text/html; charset=utf-8");
if($_POST)
{
print_r($_POST);
}
?>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
sortitems = 1; // Automatically sort items within lists? (1 or 0)

function move(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].selected && fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}

function moveall(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}


function BumpUp(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].value == "") {
for(var j=i; j<box.options.length-1; j++) {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
}
}
if(ln < box.options.length) {
box.options.length -= 1;
BumpUp(box);
}
}

function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++) {
temp_opts[i] = box.options[i];
}

for(var x=0; x<temp_opts.length-1; x++) {
for(var y=(x+1); y<temp_opts.length; y++) {
if(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
}
}
}

for(var i=0; i<box.options.length; i++) {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}
// End -->
</script>

<form ACTION="" METHOD="POST">
<table border="0">
<tr>
<td><select multiple size="7" name="list1" style="width:250px">
<option value="11">1.1 </option>
<option value="12">1.2 </option>
<option value="13">1.3 </option>
</select></td>
<td>
<input type="button" value=" >> " onclick="moveall(this.form.list1,this.form.list2)" name="B3">
<br/>
<input type="button" value=" > " onclick="move(this.form.list1,this.form.list2)" name="B1">
<br/>
<input type="button" value=" < " onclick="move(this.form.list2,this.form.list1)" name="B2">
<br/>

<input type="button" value=" << " onclick="moveall(this.form.list2,this.form.list1)" name="B4">
</td>
<td><select multiple size="7" name="list2" style="width:250px">
<option value="21">2.1 </option>
<option value="22">2.2 </option>
<option value="23">2.3 </option>
</select></td>
</tr>
</table>
<input type = 'submit' value = '提交'>
</form>
代码挺多,不过用的时候粘贴就好 里面大部分是js代码 我要的结果是 提交之后list2框里面的值 结果用php接收 我不会ajax 最好不要用jquery 看着太费劲 麻烦各位网友了
最佳答案
  • 二级知识专家网友:蜜罐小熊
  • 2021-04-27 16:39
function getthepostvalues()
{
var thepostvalues;
for(var i=0; i<form.list2.options.length; i++)
{
if(form.list2.options[i].value != "")
{
thepostvalues=thepostvalues+form.list2.options[i].value+",";
}
}
form.thepostvalue.value=thepostvalues;
return true;
}
// End -->
</script>
<form action="savetest.php" method="POST" enctype="multipart/form-data" onSubmit="getthepostvalues();" name="form">
<input type="hidden" name="thepostvalue">
全部回答
  • 1楼网友:气场征服一切
  • 2021-04-27 17:17
- -怎么搞个PHP的 我在网吧本地都测试不了 郁闷
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息