只能通过再提交重新执行PHP程序。<select name='s1' onchange="submit()">

解决方案 »

  1.   

    <?
       require("conn.php");
       $sql="select * from table1";
       $ro=mysql_query($sql);
     ?>
    <html>
    <head>
    <title>新闻添加</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    <!--
        function check(){
             if(document.form1.news_title.value=="")
             {
                 alert("警告:\n没有填写新闻标题!")
                 document.form1.news_title.select()
                 return false
                 }
             if(document.form1.news_sort.value==-1)
             {
                 alert("警告:\n没有选择新闻分类!")
                 document.form1.news_sort.focus()
                 return false
                 }
             if(document.form1.city.value==-1)
             {
                 alert("警告:\n没有选择新闻二级分类!")
                 document.form1.city.focus()
                 return false
                 }
             if(document.form1.news_message.value=="")
             {
                 alert("警告:\n没有填写新闻内容!")
                 document.form1.news_message.select()
                 return false
                 }
             
         document.form1.submit()
        return true
        }
       function cls()
    {
          document.form1.news_title.value=""
      document.form1.news_author.value=""
      document.form1.news_message.value=""
     
       }
     function change_area()
    {
    var item_title = new Array;
    <?
    $j=0;
    while($rp=mysql_fetch_array($ro))
    {
    $kk= "\"".$rp["sort_name"]."&".$rp["sort_name1"]."\"\n";
    ?>
    item_title[<?echo $j;?>]=<? echo $kk;?>
    <?
    $j=$j+1;
    }
    ?>
    if (document.form1.city.value!="-1")
    {
         for(var i=0;i<document.form1.city.length;i++)
         { 
            document.form1.city.options[0]= null;
         }
    }
    var menu;
    var j;
    j=0;
    for(var i=0;i<item_title.length;i++)
    {
      menu=item_title[i].split("&");
      if(menu[0]==document.form1.news_sort.value)
        {
    document.form1.city.options[j]= new Option(menu[1],menu[1]);
    j++;
       }
    }
    if(j==0) 
    {
        document.form1.city.options[0]= new Option("----请选择分类----","-1");
    }
    }
    //-->
    </script><link rel="stylesheet" href="../../css/1.css" type="text/css">
    </head><body bgcolor="#cccccc" text="#000000" topmargin="0"  leftmargin="0">
    <form name="form1" enctype="multipart/form-data" method="post" action="savenew.php?mode=ok" onSubmit="return check();">
    <?include("news_title.php")?>
      <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center" class="word">
        <tr> 
          <td> &nbsp;&nbsp;&nbsp;
            <center>
              <b>新闻添加 </b>
    </center>
          </td>
          <td rowspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>
            <div align="right">说明:带<font color="#FF0000">*</font>为必填项</div>
          </td>
        </tr>
        <tr valign="top"> 
          <td height="211"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="3%" height="214">&nbsp;</td>
                <td width="97%" height="214" valign="top" bgcolor="#F7F7F7"> 
                  <table width="100%" border="1" bgcolor="#cccccc" bordercolorlight="#000000" cellspacing="0" bordercolordark="#FFFFFF" cellpadding="0" class="word">
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻标题<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%"> 
                        <input type="text" name="news_title" size="50">
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻作者:</div>
                      </td>
                      <td width="76%"> 
                        <input type="text" name="news_author">
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻分类<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%"> 
                        <select name="news_sort" size=1 onChange="change_area()">
                          <option value="-1" selected>----请选择分类----</option>
                          <?
      $sql="select * from table";
              $ry=mysql_query($sql);
      while($rl=mysql_fetch_array($ry))
      {
      ?>
                          <option value="<?echo $rl["sort_id"];?>"> 
                          <?echo $rl["sort_name"];?>
                          </option>
                          <?
      }
      ?>
                        </select>
                        <a href="news_sort.php" class="word">&lt;&lt;&lt;添加分类 </a> </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="13"> 
                        <div align="center">二级分类<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%" height="13"> 
                        <select name="city" size=1 >
                          <option value="-1" selected>----请选择分类----</option>
                        </select>
                        <a href="news_sort1.php" class="word">&lt;&lt;&lt;添加二级分类</a> </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="7"> 
                        <center>
                          新闻专集
    </center>
                      </td>
                      <td width="76%" height="7">
                        <select name="new_group">
    <option value="">---请选择新闻专集---</option>
         <?
     $sqll="select group_name,group_code from news_group";
     $rtk=mysql_query($sqll);
     while($rpl=mysql_fetch_array($rtk))
     {
     ?>
                          <option value="<?echo $rpl["group_code"];?>"><?echo $rpl["group_name"];?></option>
      <?
      }
      ?>
                        </select>
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="7">
                        <center>
                          新闻图片: 
                        </center>
                      </td>
                      <td width="76%" height="7">
                        <input type="file" name="pic" size="30">
                      </td>
                    </tr>
                    <tr> 
                      <td height="12" valign="top"> 
                        <div align="center">新闻内容<font color="#FF0000">*</font>:</div>
                        <div align="center">&nbsp;</div>
                      </td>
                      <td> 
                        <textarea name="news_message" cols="50" rows="9"></textarea>
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">首页显示:</div>
                      </td>
                      <td width="76%"> 
                        <input type="radio" name="news_on" value="0" checked>
                        显示 
                        <input type="radio" name="news_on" value="1">
                        不显示 </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <center>
                          语 种: 
                        </center>
                      </td>
                      <td width="76%"> 
                        <input type="radio" name="lan" value="ch" checked>
                        中文 
                        <input type="radio" name="lan" value="en">
                        英文</td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
          <td height="211" width="5%">&nbsp;</td>
        </tr>
        <tr> 
          <td colspan="2"> 
            <center>
              <input type="submit" name="Submit" value="添加">
              <input type="reset" name="Submit2" value="取消">
            </center>
          </td>
        </tr>
      </table>
    </form></body>
    </html>
      

  2.   

    <?
       require("conn.php");
       $sql="select * from table1";
       $ro=mysql_query($sql);
     ?>
    <html>
    <head>
    <title>新闻添加</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    <!--
        function check(){
             if(document.form1.news_title.value=="")
             {
                 alert("警告:\n没有填写新闻标题!")
                 document.form1.news_title.select()
                 return false
                 }
             if(document.form1.news_sort.value==-1)
             {
                 alert("警告:\n没有选择新闻分类!")
                 document.form1.news_sort.focus()
                 return false
                 }
             if(document.form1.city.value==-1)
             {
                 alert("警告:\n没有选择新闻二级分类!")
                 document.form1.city.focus()
                 return false
                 }
             if(document.form1.news_message.value=="")
             {
                 alert("警告:\n没有填写新闻内容!")
                 document.form1.news_message.select()
                 return false
                 }
             
         document.form1.submit()
        return true
        }
       function cls()
    {
          document.form1.news_title.value=""
      document.form1.news_author.value=""
      document.form1.news_message.value=""
     
       }
     function change_area()
    {
    var item_title = new Array;
    <?
    $j=0;
    while($rp=mysql_fetch_array($ro))
    {
    $kk= "\"".$rp["sort_name"]."&".$rp["sort_name1"]."\"\n";
    ?>
    item_title[<?echo $j;?>]=<? echo $kk;?>
    <?
    $j=$j+1;
    }
    ?>
    if (document.form1.city.value!="-1")
    {
         for(var i=0;i<document.form1.city.length;i++)
         { 
            document.form1.city.options[0]= null;
         }
    }
    var menu;
    var j;
    j=0;
    for(var i=0;i<item_title.length;i++)
    {
      menu=item_title[i].split("&");
      if(menu[0]==document.form1.news_sort.value)
        {
    document.form1.city.options[j]= new Option(menu[1],menu[1]);
    j++;
       }
    }
    if(j==0) 
    {
        document.form1.city.options[0]= new Option("----请选择分类----","-1");
    }
    }
    //-->
    </script><link rel="stylesheet" href="../../css/1.css" type="text/css">
    </head><body bgcolor="#cccccc" text="#000000" topmargin="0"  leftmargin="0">
    <form name="form1" enctype="multipart/form-data" method="post" action="savenew.php?mode=ok" onSubmit="return check();">
    <?include("news_title.php")?>
      <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center" class="word">
        <tr> 
          <td> &nbsp;&nbsp;&nbsp;
            <center>
              <b>新闻添加 </b>
    </center>
          </td>
          <td rowspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>
            <div align="right">说明:带<font color="#FF0000">*</font>为必填项</div>
          </td>
        </tr>
        <tr valign="top"> 
          <td height="211"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="3%" height="214">&nbsp;</td>
                <td width="97%" height="214" valign="top" bgcolor="#F7F7F7"> 
                  <table width="100%" border="1" bgcolor="#cccccc" bordercolorlight="#000000" cellspacing="0" bordercolordark="#FFFFFF" cellpadding="0" class="word">
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻标题<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%"> 
                        <input type="text" name="news_title" size="50">
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻作者:</div>
                      </td>
                      <td width="76%"> 
                        <input type="text" name="news_author">
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">新闻分类<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%"> 
                        <select name="news_sort" size=1 onChange="change_area()">
                          <option value="-1" selected>----请选择分类----</option>
                          <?
      $sql="select * from table";
              $ry=mysql_query($sql);
      while($rl=mysql_fetch_array($ry))
      {
      ?>
                          <option value="<?echo $rl["sort_id"];?>"> 
                          <?echo $rl["sort_name"];?>
                          </option>
                          <?
      }
      ?>
                        </select>
                        <a href="news_sort.php" class="word">&lt;&lt;&lt;添加分类 </a> </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="13"> 
                        <div align="center">二级分类<font color="#FF0000">*</font>:</div>
                      </td>
                      <td width="76%" height="13"> 
                        <select name="city" size=1 >
                          <option value="-1" selected>----请选择分类----</option>
                        </select>
                        <a href="news_sort1.php" class="word">&lt;&lt;&lt;添加二级分类</a> </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="7"> 
                        <center>
                          新闻专集
    </center>
                      </td>
                      <td width="76%" height="7">
                        <select name="new_group">
    <option value="">---请选择新闻专集---</option>
         <?
     $sqll="select group_name,group_code from news_group";
     $rtk=mysql_query($sqll);
     while($rpl=mysql_fetch_array($rtk))
     {
     ?>
                          <option value="<?echo $rpl["group_code"];?>"><?echo $rpl["group_name"];?></option>
      <?
      }
      ?>
                        </select>
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%" height="7">
                        <center>
                          新闻图片: 
                        </center>
                      </td>
                      <td width="76%" height="7">
                        <input type="file" name="pic" size="30">
                      </td>
                    </tr>
                    <tr> 
                      <td height="12" valign="top"> 
                        <div align="center">新闻内容<font color="#FF0000">*</font>:</div>
                        <div align="center">&nbsp;</div>
                      </td>
                      <td> 
                        <textarea name="news_message" cols="50" rows="9"></textarea>
                      </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <div align="center">首页显示:</div>
                      </td>
                      <td width="76%"> 
                        <input type="radio" name="news_on" value="0" checked>
                        显示 
                        <input type="radio" name="news_on" value="1">
                        不显示 </td>
                    </tr>
                    <tr> 
                      <td width="19%"> 
                        <center>
                          语 种: 
                        </center>
                      </td>
                      <td width="76%"> 
                        <input type="radio" name="lan" value="ch" checked>
                        中文 
                        <input type="radio" name="lan" value="en">
                        英文</td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
          <td height="211" width="5%">&nbsp;</td>
        </tr>
        <tr> 
          <td colspan="2"> 
            <center>
              <input type="submit" name="Submit" value="添加">
              <input type="reset" name="Submit2" value="取消">
            </center>
          </td>
        </tr>
      </table>
    </form></body>
    </html>
      

  3.   

    为什么不用php哪.
    混用好象不好使.