我用document.getElementById(reobj).outerHTML="<select id='member' style='width:100px'>"+option+ "</select>";生成的联动菜单,但是看源码里没有option选项,如何把值取到并提交到PHP页面里去处理呢??谢谢,在线等
解决方案 »
- datalist遍历问题
- js中的prototype
- JAVASCRIPT动态增加表格,如何实现两个input 值的计算结果
- select multiple 的问题
- javascript
- 那位帮帮我呀!!!!!!问题多多...求动态生成TABLE代码..真心感谢
- 怎样使<input name="ddd" value="eeeee">中的 value 不可见 ,即再页面上看不见值 eeeee
- 救助:ie 5和ie 6有什么区别。为什么我写的程序在ie 5中会使ie关闭?
- 如何去掉ie工具栏,状态栏
- 在超链接时,如何控制窗口的大小,且没有工具条,状态条。
- 如何循环得到总金额?................如何循环得到总金额?................非常感谢大家
- 如何得到textarea中未选中的值~
这个在源文件里面是看不到,js这样赋值是在内在里面的。界面上是可以显示的还有,
你想怎样提交给php页面呢?
是选择select时提交给php?
加个name,然后和取text一样处理,就能取到选中的直
如果要option的所有值,要用js把option的所有值做成字符传,夫给hidden,再取hidden
我再试下楼上说的方法,谢谢
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>aaaa</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<body onload="cc()"><input type="button" onclick="cc()">
<select name="sel">
<option value="a">11</option>
<option value="b">22</option>
</select>
<input type="hidden" name="bbb">
<script>
function cc(){
var a=document.getElementsByName("sel")[0].options
var c=""
for(var i=0;i<a.length;i++){
c=c+a[i].value+","
}
alert(c)
document.getElementsByName("bbb")[0].value=c
}
</script>
</body>
</html>下个页面取bbb的、值,和text一样,然后分割数组
<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);
}
function getvalue(x){
var memberl=x;
alert(memberl);
}
</script>
<table width="80%" border="0" cellspacing="5" cellpadding="0" align="center">
<form method="post" action="main.php?mod=work&file=workdispose" name="myform">
<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">
</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" onfocus="getvalue(myform.right_sesect[index]);" 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>