代码如下:用DW打开就行了,就是右边的列表框,怎么把值传回去给PHP呢,现在传不回去:<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" type="text/javascript">
var http_request=false;
function send_request(url,y){//初始化,指定处理函数,发送请求的函数
dept=y;
http_request=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){//Mozilla浏览器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//设置MIME类别
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE浏览器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
if(!http_request){//异常,创建对象实例失败
window.alert("创建XMLHttp对象失败!");
return false;
}
http_request.onreadystatechange=processrequest;
//确定发送请求方式,URL,及是否同步执行下段代码
content='dept='+encodeURIComponent(dept);
http_request.open("POST",url,true);
http_request.setRequestHeader("Content-Length",content.length);
http_request.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
http_request.Send(content);
}
//处理返回信息的函数
function processrequest(){
if(http_request.readyState==4){//判断对象状态
if(http_request.status==200){//信息已成功返回,开始处理信息
var option=http_request.responseText;
document.getElementById(reobj).outerHTML="<select name='member' id='member' style='width:100px'>"+option+ "</select>";
document.getElementById(reobj2).outerHTML="<select id='left_select' name='left_select' size='15' style='width:100px' >"+option+"</select>";
//
//output(option);//document.form1.member.write(option);
//alert(http_request.responseText);
}
else{//页面不正常
alert("您所请求的页面不正常!");
}
}
}
function getclass(obj,obj1,x){
var pid=x;
//document.getElementById(obj).outerHTML="<select id='member' style='width:100px'> <option>loading...</option> </select>";
send_request('main.php?file=ajaxdata',pid);
reobj=obj;
reobj2=obj1;
//alert(pid);
}</script>
<table width="80%" border="0" cellspacing="5" cellpadding="0" align="center">
<form method="post" action="main.php?mod=work&file=workdispose" name="myform" onsubmit="selectAll(this.right_select);">
<tr>
<td width="15%" align="center">工作名称</td>
<td colspan="3"><input type="text" name="workname"></td>
</tr>
<tr>
<td align="center">发布日期</td>
<td colspan="3"><input type="text" name="begintime"></td>
</tr>
<tr>
<td align="center">截止日期</td>
<td colspan="2"><input type="text" name="endtime"></td>
<td>工作状态
<input type="text" name="work_estate" /></td>
</tr>
<tr>
<td align="center">关键字</td>
<td colspan="3"><input name="workkey" type="text" size="50"></td>
</tr>
<tr>
<td align="center">工作描述</td>
<td colspan="3"><{$editor}></td>
</tr>
<tr>
<td align="center">负责人</td>
<td><select name="prin" style="width:90px" onchange="if(this.value != 'select')getclass('member','left_select',this.options[this.selectedIndex].value)">
<option value="select" selected="selected" >请选择部门</option>
<{foreach key=key item=value from=$dept}>
<option value="<{$key}>" ><{$key}></option>
<{/foreach}>
</select></td>
<td>部门</td>
<td><select name="member" id="member" style="width:100px" >
</select> 成员 </td>
</tr>
<tr>
<td align="center">成员</td>
<td width="17%"><select id="selectl" name="left_select" size="15" style="width:100px" multiple>
</select> </td>
<td width="8%">
<table>
<tr>
<td><INPUT language="javascript" name="btn_select_addany" onclick="fun_select_addany(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title="Add any" type=button value="8"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_addall" onclick="fun_select_addall(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title="Add all" type=button value=: DESIGNTIMESP="17713"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_dltany" onclick="fun_select_dltany(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title ="delete any" type=button value="7"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_dltall" onclick="fun_select_dltall(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title ="delete all" type=button value="9"></td>
</tr>
</table> </td>
<td width="60%"><select id="selmember" name="right_select" size="15" style="width:100px" multiple>
</select></td>
</tr>
</td>
</tr>
<tr>
<td align="center"> </td>
<td colspan="3"><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
<script language="javascript">
function fun_select_addany(theform){
var i;
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].selected == true){
if (theform.left_select.options[i].text !=""){
theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text);
theform.left_select.options[i] =new Option("");
}
}
}
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].text ==""){theform.left_select.options.remove(i); i--;}
}
} function fun_select_addall(theform){
var i;
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].text !=""){
theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text);
}
}
theform.left_select.length=0;
} function fun_select_dltany(theform){
var i;
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].selected == true){
if (theform.right_select.options[i].text !=""){
theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text);
theform.right_select.options[i] =new Option("");
}
}
}
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].text ==""){theform.right_select.options.remove(i);i--;}
}
}function fun_select_dltall(theform){
var i;
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].text !=""){
theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text);
}
}
theform.right_select.length=0;
}
</script>
<script language="JavaScript" type="text/javascript">
var http_request=false;
function send_request(url,y){//初始化,指定处理函数,发送请求的函数
dept=y;
http_request=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){//Mozilla浏览器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//设置MIME类别
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE浏览器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
if(!http_request){//异常,创建对象实例失败
window.alert("创建XMLHttp对象失败!");
return false;
}
http_request.onreadystatechange=processrequest;
//确定发送请求方式,URL,及是否同步执行下段代码
content='dept='+encodeURIComponent(dept);
http_request.open("POST",url,true);
http_request.setRequestHeader("Content-Length",content.length);
http_request.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
http_request.Send(content);
}
//处理返回信息的函数
function processrequest(){
if(http_request.readyState==4){//判断对象状态
if(http_request.status==200){//信息已成功返回,开始处理信息
var option=http_request.responseText;
document.getElementById(reobj).outerHTML="<select name='member' id='member' style='width:100px'>"+option+ "</select>";
document.getElementById(reobj2).outerHTML="<select id='left_select' name='left_select' size='15' style='width:100px' >"+option+"</select>";
//
//output(option);//document.form1.member.write(option);
//alert(http_request.responseText);
}
else{//页面不正常
alert("您所请求的页面不正常!");
}
}
}
function getclass(obj,obj1,x){
var pid=x;
//document.getElementById(obj).outerHTML="<select id='member' style='width:100px'> <option>loading...</option> </select>";
send_request('main.php?file=ajaxdata',pid);
reobj=obj;
reobj2=obj1;
//alert(pid);
}</script>
<table width="80%" border="0" cellspacing="5" cellpadding="0" align="center">
<form method="post" action="main.php?mod=work&file=workdispose" name="myform" onsubmit="selectAll(this.right_select);">
<tr>
<td width="15%" align="center">工作名称</td>
<td colspan="3"><input type="text" name="workname"></td>
</tr>
<tr>
<td align="center">发布日期</td>
<td colspan="3"><input type="text" name="begintime"></td>
</tr>
<tr>
<td align="center">截止日期</td>
<td colspan="2"><input type="text" name="endtime"></td>
<td>工作状态
<input type="text" name="work_estate" /></td>
</tr>
<tr>
<td align="center">关键字</td>
<td colspan="3"><input name="workkey" type="text" size="50"></td>
</tr>
<tr>
<td align="center">工作描述</td>
<td colspan="3"><{$editor}></td>
</tr>
<tr>
<td align="center">负责人</td>
<td><select name="prin" style="width:90px" onchange="if(this.value != 'select')getclass('member','left_select',this.options[this.selectedIndex].value)">
<option value="select" selected="selected" >请选择部门</option>
<{foreach key=key item=value from=$dept}>
<option value="<{$key}>" ><{$key}></option>
<{/foreach}>
</select></td>
<td>部门</td>
<td><select name="member" id="member" style="width:100px" >
</select> 成员 </td>
</tr>
<tr>
<td align="center">成员</td>
<td width="17%"><select id="selectl" name="left_select" size="15" style="width:100px" multiple>
</select> </td>
<td width="8%">
<table>
<tr>
<td><INPUT language="javascript" name="btn_select_addany" onclick="fun_select_addany(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title="Add any" type=button value="8"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_addall" onclick="fun_select_addall(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title="Add all" type=button value=: DESIGNTIMESP="17713"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_dltany" onclick="fun_select_dltany(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title ="delete any" type=button value="7"></td>
</tr>
<tr>
<td><INPUT language="javascript" name="btn_select_dltall" onclick="fun_select_dltall(document.myform)" style="COLOR: blue; FONT-FAMILY: Webdings; FONT-SIZE: 12pt; FONT-WEIGHT: normal; HEIGHT: 28px; WIDTH: 27px" title ="delete all" type=button value="9"></td>
</tr>
</table> </td>
<td width="60%"><select id="selmember" name="right_select" size="15" style="width:100px" multiple>
</select></td>
</tr>
</td>
</tr>
<tr>
<td align="center"> </td>
<td colspan="3"><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
<script language="javascript">
function fun_select_addany(theform){
var i;
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].selected == true){
if (theform.left_select.options[i].text !=""){
theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text);
theform.left_select.options[i] =new Option("");
}
}
}
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].text ==""){theform.left_select.options.remove(i); i--;}
}
} function fun_select_addall(theform){
var i;
for (i=0;i<theform.left_select.length;i++){
if (theform.left_select.options[i].text !=""){
theform.right_select.options[theform.right_select.length]=new Option(theform.left_select.options[i].text);
}
}
theform.left_select.length=0;
} function fun_select_dltany(theform){
var i;
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].selected == true){
if (theform.right_select.options[i].text !=""){
theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text);
theform.right_select.options[i] =new Option("");
}
}
}
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].text ==""){theform.right_select.options.remove(i);i--;}
}
}function fun_select_dltall(theform){
var i;
for (i=0;i<theform.right_select.length;i++){
if (theform.right_select.options[i].text !=""){
theform.left_select.options[theform.left_select.length]=new Option(theform.right_select.options[i].text);
}
}
theform.right_select.length=0;
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货