你现在的设计是不行的,有两种方法可以用:
方法1:
<form name="choiceForm">
改为
<form name="choiceForm" onsubmit="return commit();">
<input type="hidden" action="aaa.php" method="get" name="ids">
<script language="javascript">
function commit(){
document.choiceForm.ids.value = strValues;
return true;
}
</script>方法2:
<form name="choiceForm">
改为
<form name="choiceForm" onsubmit="return commit();">
<script language="javascript">
function commit(){
document.location = "aaa.php?ids="+strValues;
return false;
}
</script>-------------------------------------------------------
另外建立一个aaa.php文件:
<?
echo $_GET['ids'];
?>这样就可以看到效果了。代码没测试过,有错误自己动手调把
方法1:
<form name="choiceForm">
改为
<form name="choiceForm" onsubmit="return commit();">
<input type="hidden" action="aaa.php" method="get" name="ids">
<script language="javascript">
function commit(){
document.choiceForm.ids.value = strValues;
return true;
}
</script>方法2:
<form name="choiceForm">
改为
<form name="choiceForm" onsubmit="return commit();">
<script language="javascript">
function commit(){
document.location = "aaa.php?ids="+strValues;
return false;
}
</script>-------------------------------------------------------
另外建立一个aaa.php文件:
<?
echo $_GET['ids'];
?>这样就可以看到效果了。代码没测试过,有错误自己动手调把
是不是
<input type="button" value="删除" onclick="removeMe();">
<input type="button" value="结果" onclick="saveMe();">
代码那里还需要修改,onclick="saveMe();"应该修改成什么样呢?
javascript硬是搞不懂.
修改成<input type=submit value="结果" >后,提交的还是本页,并非aaa.php!
--------------------------
<?
echo $_POST["strValues"];
?>本页
-------------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function saveMe() {
var strValues = "";
var boxLength = document.choiceForm.choiceBox.length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.choiceForm.choiceBox.options[i].value;
}
else {
strValues = strValues + "|" + document.choiceForm.choiceBox.options[i].value;
}
count++;
}
}
if (strValues.length == 0) {
alert("您没有选择任何内容");
}
else {
document.choiceForm.strValues.value=strValues;
document.choiceForm.submit();
}
}
// End -->
</script>
<center>
<form name="choiceForm" action="aaa.php" method="post">
<input type="hidden" name="strValues" value="">
<table border=0>
<tr>
<td valign="top" width=175>
<div align="center">可选内容:<br>
<select name="available" size=10 onchange="moveOver();">
<option value="1">内容一</option>
<option value="2">内容二</option>
<option value="3">内容三</option>
<option value="4">内容四</option>
<option value="5">内容五</option>
<option value="6">内容六</option>
<option value="7">内容七</option>
<option value="8">内容八</option>
<option value="9">内容九</option>
<option value="10">内容十</option>
</select>
</div>
</td>
<td valign="top">
<div align="center">你的选择:<br>
<select multiple name="choiceBox" style="width:175;" size="10">
</select>
</div>
</td>
</tr>
<tr>
<td align=right>信息标题:</td>
<td><input type=text name=title size=30 value="信息标题" MAXLENGTH="40"></td>
</tr>
<tr>
<td colspan=2 height=10>
<div align="center">
<input type="button" value="删除" onclick="removeMe();">
<input type="button" value="结果" onclick="saveMe();">
</div>
</td>
</tr>
</table>
</form>
</center>
<script language="javascript">
function commit(){
document.choiceForm.ids.value = strValues;
return true;
}
</script>
<form name="choiceForm" onsubmit="commit();">
<script language="javascript">
function commit(){
document.location = "aaa.php?ids="+strValues;
}
</script