onchange="{document.form1.name1.value=document.form1.name2.value;}"

解决方案 »

  1.   

    下拉框2中的值是以下拉框1中的值为参数并经过处理得到的,举个例子:
    value2=select aaa from bbb where aaa=value1
    请问如何实现这个功能?谢谢!
    zalvsa(zalvsa) :能否说的详细些,能否给个例子?
      

  2.   

    <form name="searching">
    <SELECT NAME="sort" onchange="shows(smallsort,sort);"><option value="">公司名称</option><option value="1">公司名称1</option><option value="2">公司名称2</option><option value="3">公司名称3</option>
    </select>
    <SELECT name="smallsort" style="display:inline;" ><option value="">公司人员1</option><option value="1">王</option><option value="2">阿斯蒂芬</option><option value="3">阿斯蒂芬</option><option value="4">洒的发</option><option value="56">其他</option>
    </SELECT><SELECT name="smallsort" style="display:none;" ><option value="">公司人员2</option><option value="6">阿斯蒂芬</option><option value="7">阿斯蒂芬</option><option value="8">阿三点</option><option value="9">阿斯蒂芬</option><option value="57">其他</option>
    </SELECT><SELECT name="smallsort" style="display:none;" ><option value="">公司人员3</option><option value="14">阿斯蒂芬</option><option value="15">斯蒂芬</option><option value="16">大幅度</option><option value="17">进口量进口</option>
    <option value="29">其他人</option>
    </SELECT>
    </form>
    <script>
    function shows(smallsort,sort)
    {
    var a;
    a=document.searching.sort.selectedIndex;
    if(a==0)return;document.searching.smallsort[0].style.display='none';document.searching.smallsort[1].style.display='none';document.searching.smallsort[2].style.display='none';document.searching.smallsort[a-1].style.display='inline';
    }
    </script>
      

  3.   

    如果要经过就算只能用ASP或者JSP了。
    假如这个页面名称为11.asp
    asp程序
    <%
    dim req;
    req=request("sort");
    if req-1=0 then
    sql="select user from table where company='公司一'"
    set rs=conn.execute(sql)
    tempstr="<select name="select1" value="">"
    while not rs.eof
    tempstr=tempstr &"<option value='" & rs("user") & "'>& rs("user")&"</option>"
    rs.movenext
    wend
    elseif req-2=0 then
    ....如上
    elseif req-3=0 then
    ....如上
    else
    response.write "错误请求"
    end if
    %>
    <select name="sort" onchange="f2()">
    option value="">公司名称</option><option value="1">公司名称1</option><option value="2">公司名称2</option><option value="3">公司名称3</option></select><script>
    function f2(){
    var vr=document.searching.sort.value;
    document.location.href="11.asp?sort="+vr;
    }
    </script>
      

  4.   

    完整的程序是这样的11.asp<%
    Set Conn=Server.CreateObject("ADODB.Connection")
    Conn.open "driver={SQL Server};server=(local);uid=sa;pwd=;database=dbname"
    dim req;
    req=request("sort");
    if req-1=0 then
    sql="select user from table where company='公司一'"
    set rs=conn.execute(sql)
    tempstr="<select name="select1" value="">"
    while not rs.eof
    tempstr=tempstr &"<option value='" & rs("user") & "'>"& rs("user")&"</option>"
    rs.movenext
    wend
    elseif req-2=0 then
    sql="select user from table where company='公司一'"
    set rs=conn.execute(sql)
    tempstr="<select name="select1" value="">"
    while not rs.eof
    tempstr=tempstr &"<option value='" & rs("user") & "'>"& rs("user")&"</option>"
    rs.movenext
    wend
    elseif req-3=0 then
    sql="select user from table where company='公司一'"
    set rs=conn.execute(sql)
    tempstr="<select name="select1" value="">"
    while not rs.eof
    tempstr=tempstr &"<option value='" & rs("user") & "'>"& rs("user")&"</option>"
    rs.movenext
    wend
    else
    response.write "错误请求"
    end if
    %>
    <form name="searching">
    <select name="sort" onchange="f2()">
    <option value="">公司名称</option><option value="1">公司名称1</option><option value="2">公司名称2</option><option value="3">公司名称3</option></select>
    <%=tempstr%>
    </form>
    <script>
    function f2(){
    var vr=document.searching.sort.value;
    alert(vr);
    document.location.href="11.asp?sort="+vr;
    }
    </script>
      

  5.   

    能解释一下function shows吗?
      

  6.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=1179186
      

  7.   

    用 javascript 的 onchang 事件,
    里面可以 嵌入 php 的;一点小例子
    function myshow()
     {
       if(document.form1.schstyle.selectedIndex==0)
       {
        document.form1.schtype.options[0].text="今天";
        document.form1.schtype.options[1].text="这一周";
        document.form1.schtype.options[2].text="近一月";
        document.form1.schtype.options[3].text="近两月";
       }
    <?
     //可以嵌入 php 
    ?>
      else
       {
        document.form1.schtype.options[0].text="精确查询";
        document.form1.schtype.options[1].text="模糊查询";
        document.form1.schtype.options[2].text="前方一致";
        document.form1.schtype.options[3].text="后方一致";
       }
      document.form1.schtype.options[0].selected=true;
     }
      

  8.   

    以上是 javascript 语句,有以下语句引发函数
    <select name="schstyle" size="1" id="schstyle" onChange="myshow()">
        <option value="1">记者姓名</option>
        <option value="2" selected>文章标题</option>
      </select>
      

  9.   

    那转过来吧:
    <form name="form1" method="post">
      <table width="400" cellspacing="0" cellpadding="0">
        <tr> 
          <td colspan="2" height="42"> 
            <div align="center">新增工作任務</div>
          </td>
        </tr>
        <tr> 
          <td width="25%">
            <div align="right">任務主題</div>
          </td>
          <td width="75%"> 
            <input type="text" name="contentname" size="35">
          </td>
        </tr>
        <tr> 
          <td width="25%"> 
            <div align="right">負責人</div>
          </td>
          <td width="75%">   
            <select name="depart" onchange="sel(form1.depart,IdArr,TextArr)">
            </select>
            <select name="userid" >
            </select>
          </td>
        </tr>
        <tr> 
          <td colspan="2" height="44"> 
            <div align="center"> 
              <input type="submit" name="submit" value="保存">
              <input type="button" name="Submit2" value="離開" onclick="self.close()">
            </div>
          </td>
        </tr>
      </table>
    </form>
    <?
    $R=mysql_query("select departid,departname from depart order by id");
    $Num=mysql_num_rows($R);
    echo "<script language=javascript>\n";
    echo "form1.depart.length=$Num;\n";
    echo "IdArr=new Array();\nTextArr=new Array();\n";
    $i=0;
    while($PArr=mysql_fetch_array($R)){
    echo "IdArr[$i]='$PArr[departid]';\n";
    echo "TextArr[$i]='$PArr[departname]';\n";
    echo "form1.depart.options[$i].value='$PArr[departid]';\n";
    echo "form1.depart.options[$i].text='$PArr[departname]';\n";
    echo "IdArr[$i]=new Array();\n";
    echo "TextArr[$i]=new Array();\n";
    $m=0;
    $SR=mysql_query("select userid,realname from user where department=$PArr[departid]");
    while($SArr=mysql_fetch_array($SR)){
    echo "IdArr[$i][$m]='$SArr[userid]';\n";
    echo "TextArr[$i][$m]='$SArr[realname]';\n";
    $m++;
    }
    $i++;
    }
    echo "</script>\n";
    ?>
    <script language=javascript>
    sel(form1.depart,IdArr,TextArr);
    function sel(select,IdArray,TextArray)
    {
    index=select.selectedIndex;
    form1.userid.length=IdArray[index].length;
    for (n=0;n<IdArray[index].length;n++)
    {
    var op=form1.userid.options[n];
    op.value=IdArray[index][n];
    op.text=TextArray[index][n];
    }
    }
    </script>
      

  10.   

    如何把php中的数组变量传给javascript函数,老是报错“参数未定义”<SCRIPT language="JavaScript">function Chg(name,result,name2)
    {
        
        ChgOptions(document.all.name.selectedIndex,result,name2);
        
    }
    function ChgOptions(iSel1,iResult,iSel2)
    {
        if ( 0 <= iSel1 && iSel1 < iResult.length )
        {
            var iSel2 = document.all.iSel2, i;        //删除所有旧选项(不知道有没有不用循环的删除办法)
            for ( i = iSel2.options.length; -- i >= 0; )
                iSel2.options.remove(i);        //创建新关联选项
            var Table1dim = iResult[iSel1];
            for ( i = 0; i < Table1dim.length; i ++ )
            {
                var o = document.createElement('<option>');
                o.text = Table1dim[i];
                iSel2.options.add(o);
                
            }
        }
    }<form name="housing" method="post" action="<?$PHP_SELF?>?submit=housing" onSubmit="return checkkey()"><select name="dev_id" onchange=chg(dev_id,dev_cont,dev_contact)>
              <?
              ChgOptions(0,dev_cont,dev_contact);
              for ( $i = 0; $i < $r; $i ++ )
            {
                echo "<option value=".$dev[$i][0].">".$dev[$i][1]."</option>";        }
            ?>
             </select>   
    </form>  
    报错“dev_cont未定义”,但是dev_cont已在之前定义过了,且已取得值,不知是何原因?