0

我有这样的事情:我希望当我在下拉列表中选择任何东西时,我的提交按钮应该被触发......我已经添加了 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>
4

1 回答 1

0

按钮的命名干扰了脚本

onchange="this.form.submit()"如果您将提交按钮重命名为 mySubmit。

而且根本没有涉及 jQuery,所以我删除了标签。

如果你想要 jQuery,做

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

但是按钮的重命名是最重要的,所以你还需要

if (isset($_POST['mySubmit']))
于 2013-02-20T12:17:37.110 回答