要求是这样的,如下图:
左Select框 右Select框
A Add C
B Del E
D
submit
左Select里本来是ABCDE,当选择CE时,点Add,它们就会跑到右边去,再选C后点Del,C又会跑左边去.点击submit时,要求得到右Select框里的所有值;
代码如下:但是我不知道点submit时如何得到右边的值:(另提一问,就是怎么能让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+" | |";
}
alert(temp);
}
</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"?> </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> <a href="javascript:copyToList('possible','chosen')">add </a> <BR /> <br />
<a href="javascript: copyToList('chosen','possible')">delete </a> </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>