2013-02-20 80 views
0

我有這樣的事情:我想當我選擇下拉列表中的任何東西我的submitt按鈕應該被解僱... 我已經添加了onchange事件,即onchange去功能,我已經調用我的表單document.getElementById("frmReport").submit();更改事件

<script type = "text/javascript"> 
function go() { 
document.getElementById("frmReport").submit(); 
} 
</script>enter code here 
</head> 
<body id="homepage"> 
    <!-- Right Side/Main Content Start --> 
    <div id="rightside"> 
     <!-- Graphs Box Start --> 
     <div class="contentcontainer" id="graphs"> 
         <div class="contentbox" id="graphs-1"> 
         <form name="frmReport" id="frmReport" method="post"> 
        <table style="display: none;" class="area"> 
         <caption>VOICE-SMS SENT</caption> 
         <thead> 
          <tr> 
           <td></td> 
           <th scope="col">1</th> 
           <th scope="col">2</th> 
           <th scope="col">3</th> 
           <th scope="col">4</th> 
           <th scope="col">5</th> 
           <th scope="col">6</th> 
           <th scope="col">7</th> 
           <th scope="col">8</th> 
           <th scope="col">9</th> 
           <th scope="col">10</th> 
           <th scope="col">11</th> 
           <th scope="col">12</th> 
           <th scope="col">13</th> 
           <th scope="col">14</th> 
           <th scope="col">15</th> 
           <th scope="col">16</th> 
           <th scope="col">17</th> 
           <th scope="col">18</th> 
           <th scope="col">19</th> 
           <th scope="col">20</th> 
           <th scope="col">21</th> 
           <th scope="col">22</th> 
           <th scope="col">23</th> 
           <th scope="col">24</th> 
           <th scope="col">25</th> 
           <th scope="col">26</th> 
           <th scope="col">27</th> 
           <th scope="col">28</th> 
           <th scope="col">29</th> 
           <th scope="col">30</th> 
          </tr> 
         </thead> 
         <tbody> 
         <tr> 
           <th scope="row">TOATAL CALLS</th> 
          <?php 
          if (isset($_POST['submit'])) 
        { 
          $answer = array(); 
          for($i=1;$i<=31;$i++) { 
           $answer[$i]=0; 
          } 
          $connect = new Connection(); 
          if ($connect->openConnection()) { 
           $connect->beginTransaction(); 
           $filecount = $connect->fetchRows("CALL spTotalVoiceMonthGraphStatus('shreeweb','".date("Y")."-".$_REQUEST['cmbToYear']."-01')"); 
           //$rowcount=count($filecount); 
           //echo $rowcount; 
           if ($filecount) 
           { 
            foreach($filecount as $row) { 
             //$abc=$row['count']; 
             //echo '<td>'.$row['count'].'</td>'; 
             $answer[$row['ActualDate']]=$row['count']; 
            }     
           } 
          } 
          for($i=1;$i<=31;$i++) { 
           echo '<td>'.$answer[$i].'</td>'; 

          } 
          } 
          ?> 

          </tr> 
          <tr> 
           <th scope="row">ANSWERED CALLS</th> 
          <?php 
          if (isset($_POST['submit'])) 
        { 
          $answer = array(); 
          for($i=1;$i<=31;$i++) { 
           $answer[$i]=0; 
          } 
          $connect = new Connection(); 
          if ($connect->openConnection()) { 
           $connect->beginTransaction(); 
           $filecount = $connect->fetchRows("CALL spMonthlyGraphStatus('shreeweb','".date("Y")."-".$_REQUEST['cmbToYear']."-01')"); 
           //$rowcount=count($filecount); 
           //echo $rowcount; 
           if ($filecount) 
           { 
            foreach($filecount as $row) { 
             //$abc=$row['count']; 
             //echo '<td>'.$row['count'].'</td>'; 
             $answer[$row['ActualDate']]=$row['count']; 
            }     
           } 
          } 
          for($i=1;$i<=31;$i++) { 
           echo '<td>'.$answer[$i].'</td>'; 

          } 
          } 
          ?> 

          </tr> 
          <tr> 
           <th scope="row">Other Calls</th> 
           <?php 
           if (isset($_POST['submit'])) 
        { 
           $answer = array(); 
           for($i=1;$i<=31;$i++) { 
            $answer[$i]=0; 
           } 
           $connect = new Connection(); 
           if ($connect->openConnection()) { 
            $connect->beginTransaction(); 
            $filecount = $connect->fetchRows("CALL spMonthlyGraphStatusOthers('shreeweb','".date("Y")."-".$_REQUEST['cmbToYear']."-01')"); 
            if ($filecount) { 
             foreach($filecount as $row) { 
              $answer[$row['ActualDate']]=$row['count']; 
             }     
            } 
           } 
           for($i=1;$i<=31;$i++) { 
            echo '<td>'.$answer[$i].'</td>'; 
           } 
           } 
           ?> 
          </tr> 

         </tbody> 
         <center> 
        <select size="1" name="cmbToYear" id="cmbToYear" title="Click here to select year" onchange = "go()"> 
        <option>SELECT MONTH</option> 
         <option value="01">JAN </option> 
         <option value="02"> FEB</option> 
         <option value="03"> MAR</option> 
         <option value="04"> APR</option> 
         <option value="05"> MAY</option> 
         <option value="06"> JUN</option> 
         <option value="07"> JULY</option> 
         <option value="08"> AUG</option> 
         <option value="09"> SEP</option> 
         <option value="10"> OCT</option> 
         <option value="11"> NOV</option> 
         <option value="12 "> DEC</option> 
         </select> 
         <input type="submit" class="btn" value="Submit" name="submit" title="Click here to view the reports for sent Voice sms"> 
        </center> 
        </table> 
        </form> 
      </div> 
      </div> 

回答

0

按鈕的命名與腳本

onchange="this.form.submit()"干擾如果重命名提交按鈕mySubmit會工作。

也沒有涉及jQuery,所以我刪除了標籤。

如果你想jQuery的,做

$(function() { 
    $("#cmbToYear").on("change",function() { 
    this.form.submit(); 
    // or $("#frmReport").submit(); 
    }); 
}); 

但按鈕的重命名是最重要的 ,所以你還需要

if (isset($_POST['mySubmit'])) 
+0

爲jQuery的?我沒有,T獲得? 而yess thnx只是命名約定問題。 – sidhesh 2013-02-20 12:22:47

+0

你a)標記問題jQuery和b)標題中有jquery。但是,在你的代碼中並沒有需要或涉及到的jQuery – mplungjan 2013-02-20 12:30:37

+1

抱歉,謝謝我會牢記這一點 – sidhesh 2013-02-20 12:49:41