日期:2014-05-18  浏览次数:20364 次

请问一个<script>里函数结果怎么让一个PHP页面得到????
代码如下:我想选择右边对话框的值到左边,然后得到左边的值

<script>
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字 //你可以根据你的具体情况修改
{
  fromList = eval('document.forms[0].' + from);
  toList = eval('document.forms[0].' + to);
  if (toList.options.length > 0 && toList.options[0].value == 'temp')
  {
  toList.options.length = 0;
  }
  var sel = false;
  for (i=0;i<fromList.options.length;i++)
  {
  var current = fromList.options[i];
  if (current.selected)
  {
  sel = true;
  if (current.value == 'temp')
  {
  alert ('你不能选择这个项目!');
  return;
  }
  txt = current.text;
  val = current.value;
  toList.options[toList.length] = new Option(txt,val);
  fromList.options[i] = null;
  i--;
  }
  }
  if (!sel) alert ('你还没有选择任何项目');
}

function getValue()
{
alert(document.form1.text1.value);
var sel = document.form1.chosen;
var temp="";
for(i=0; i<sel.options.length; i++)
{
temp += sel.options[i].value;
temp += sel.options[i].text+"||";
}
//temp里的值是正确的
document.form1.choice.value= temp;//我想让PHP得到这个temp里的值,也就是选择的几项;为什么我在PHP里用$_post['choice']得不到???
}
</script>

<form action="index.php" name="myForm" method="post" onsubmit="alert(document.myForm.choice.value)">
  <table class="listing" border="0" cellspacing="0" cellpadding="0" width="780">
<tr class="detailrow<?php echo ($_rc = 1 - $_rc)?>">
  <td align=left valign=center height = "80"><?php echo "Select CommissionCharge"?>&nbsp;&nbsp;</td>
  <td><select name="possible" size="8" align=left multiple style="width: 200px;>
  <option value="1">yy</option>
  <option value="2">gz</option>
  <option value="3">sz</option>
  <option value="4">wh</option>
  <option value="5">sh</option>
  </select></td>
  <td>&nbsp;&nbsp;<a href="javascript:copyToList('possible','chosen')">add</a>&nbsp;&nbsp;<BR /><br />
&nbsp;&nbsp;<a href="javascript: copyToList('chosen','possible')">delete</a>&nbsp;&nbsp;</td>
  <td><select name="chosen" size="8" align=left multiple style="width: 200px;">
  <option value="temp"></option>
  </select></td>
  </tr>
   
  <tr>
  <td align=left>
  <table border=0 cellspacing=0 cellpadding=5>
  <tr>
  <td>
  <input type="hidden" name=choice value= " "/> //在这里设个空值,当传值用
  <input class="formbutton" type="submit" value="提交" onclick="getValue();/>
   
  </td>
  </tr>
  </table>
&n