使用输入类型按钮而不是按钮元素来避免表单数据丢失

时间:2017-10-16 19:11:27

标签: jquery

我讨厌第二次发布我的问题,但似乎我的原始查询(Why won't my jquery display correctly)可能已被遗忘。对于庞大的代码块感到抱歉,但我想我会将其全部包含在内,以尝试全面了解。目前,当我点击“设置时间”时,按钮,当前时间在输入字段中闪烁,然后消失。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <!--<style media="screen"></style>-->

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Crime Stoppers</title>



        <script src="./jquery/js/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="./jquery/css/jquery-ui.css"/>
        <link rel="stylesheet" href="./jquery/css/jquery.timepicker.css"/>
        <script type="text/javascript" src="./jquery/js/jquery.timepicker.js"></script>

        <script type="text/javascript">

            $(document).ready(function () {
                $('#basicExample').timepicker();
                $('#setTimeButton').on('click', function () {
                    $('#basicExample').timepicker('setTime', new Date());
                })
            });
        </script>
    </head>
    <body>
    <div id="header" align="center"><img src="./images/document.png" alt="header"/></div>
    <ul>
        <li><a href="Search.php">Search</a></li>
    </ul>

    <!-- Div basically wrap can center, sometimes give it ID and us JS to do stuff within -->
    <div align="center">

        <h1>Crime Stoppers Report</h1>

        <form class="formLayout" action="Violent.php" method="POST">

            <fieldset class="table">
                <legend>Crime</legend>
                <div class="tr">
                    <div class="td"><input type="radio" name="crimeType" value="1" checked> Violent Crime</div>
                    <div class="td"><input type="radio" name="crimeType" value="2"> Drug Crime</div>
                    <div class="td"><input type="radio" name="crimeType" value="3"> Property Crime</div>
                    <div class="td"><input type="radio" name="crimeType" value="4"> Other (e.g. traffic)</div>
                </div>


                <div class="tr">

                    <div class="td right">Caller code Number:</div>
<!--                    not using callerCodeNum or caseNum as they are the same as CrimeID-->
                    <div class="td"><input type="text" name="callerCodeNum" value="<?php echo $row['CrimeID'] + 1;?>"></div>

                    <div class="td right">Case Number:</div>
                    <div class="td"><input type="text" name="caseNum" value="<?php echo $row['CrimeID'] + 1;?>"></div>

                </div>
                <div class="tr">
                    <div class="td right">Date of Call:</div>
                    <div class="td"><input type="text" class="datepicker" name="callDate"></div>
                    <div class="td right">Time of Call:</div>
<!--                    <div class="td"><input type="text" class="basicExample" name="callTime"></div>-->
                    <div class="td"><input type="text" id="basicExample" name="callTime"></div>

                </div>
                <button id="setTimeButton">set time</button>

                <div class="tr">

                    <div class="td right">Date of Offense:</div>
                                        <div class="td"><input type="text" class="datepicker2" name="crimeDate"></div>
<!--                    <div class="td right">Time of Offense:</div>-->
<!--                                        <div class="td"><input type="text" class="timepicker" name="crimeTime"></div>-->

                </div>
                <div class="tr">
                    <div class="td right">Is there a warrant?</div>
                    <div class="td"><select name="warrExists">
                            <option value="0">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>
                    <div class="td right">If so what is the jurisdiction?</div>
                    <div class="td"><input type="text" name="jurisdiction"></div>

                    <div class="td right">Warrant Type: </div>
                    <div class="td"><select name="warrType">
                            <option value="na">N/A</option>
                            <option value="city">City</option>
                            <option value="felony">Felony</option>
                            <option value="misdem">Misdemeanor</option>
                        </select></div>
                </div>
                <div class="tr">
                    <div class="td right">Case Closed?</div>
                    <div class="td"><input type="radio" name="CriFileClosed" value="1" checked> No
                    </div>
                    <div class="td"><input type="radio" name="CriFileClosed" value="2"> Yes</div>
                    <div class="td right">Info Unfounded?</div>
                    <div class="td"><input type="radio" name="CriInfoUnfound" value="1" checked> No
                    </div>
                    <div class="td"><input type="radio" name="CriInfoUnfound" value="2"> Yes</div>
                </div>
                <div class="tr">
                    <div class="td right">Pending Further Investigation</div>
                    <div class="td"><input type="radio" name="CriFurthInvest" value="1" checked> No
                    </div>
                    <div class="td"><input type="radio" name="CriFurthInvest" value="2"> Yes</div>
                </div>
            </fieldset>


            <fieldset class="table">
                <legend>Victim</legend>
                <div class="tr">
                    <div class="td right">First Name:</div>
                    <div class="td"><input type="text" name="vicFirstName" value="N/A"></div>
                    <div class="td right">Last Name:</div>
                    <div class="td"><input type="text" name="vicLastName" value="N/A"></div>
                    <div class="td right">Age:</div>
                    <!--                                        <div class="td"><input type="text" name="vicAge" value="N/A"></div>-->
                    <div class="td"><select name="vicAge">

                            <?php
                            foreach ($age_array as $age) {
                                ?>
                                <option value="<?php echo $age; ?>"><?php echo $age; ?></option>
                            <?php }
                            ?>
                        </select></div>
                </div>
                <div class="tr">
                <div class="td right">Business name:</div>
                    <div class="td"><input type="text" name="vicBusName" value="N/A"></div>
                </div>
            </fieldset>


            <fieldset class="table">
                <legend>Suspect #1</legend>
                <div class="tr">
                    <div class="td"><input type="radio" name="susDrugIntent" value="1"> Using</div>
                    <div class="td"><input type="radio" name="susDrugIntent" value="2"> Dealing</div>
                    <div class="td"><input type="radio" name="susDrugIntent" value="3"> Both</div>
                    <div class="td"><input type="radio" name="susDrugIntent" value="4" checked> N/A</div>
                </div>
                <div class="tr">
                    <div class="td right">Drug Type:</div>
                    <div class="td"><input type="text" name="drugType" value="N/A"></div>
                    <div class="td right">Qty:</div>
                    <div class="td"><input type="text" name="drugQty" value="N/A"></div>
                    <div class="td right">Pills?</div>
                    <div class="td"><input type="text" name="drugPills" value="N/A"></div>
                </div>
                <div class="tr">
                    <!---->
                    <div class="td right">First Name:</div>
                    <div class="td"><input type="text" name="susFirstName"></div>
                    <div class="td right">Last Name:</div>
                    <div class="td"><input type="text" name="susLastName"></div>
                    <div class="td right">Middle Initial:</div>
                    <div class="td"><input type="text" name="susMiddleInitial"></div>
                </div>
                <div class="tr">
                    <div class="td right">Alias:</div>
                    <div class="td"><input type="text" name="susAlias" value="N/A"></div>
                </div>

                <div class="tr">
                    <div class="td right">DOB:</div>
                    <div class="td"><input class="datepicker2" name="susDob"></div>

                    <!--                    <div class="td"><input type="text" class="userDate">-->
                    <!--                        <input type="hidden" class="dbDate" name="susDob"></div>-->


                    <div class="td right">Sex:</div>

                    <div class="td"><select name="susSex">
                            <option value="3">Unknown</option>
                            <option value="1">Male</option>
                            <option value="2">Female</option>
                        </select></div>
                    <div class="td right">Race:</div>
                    <div class="td"><select name="susRace">
                            <option value="1">White</option>
                            <option value="2">Black</option>
                            <option value="3">Hispanic</option>
                            <option value="4">Asian</option>
                            <option value="5">Native American</option>
                            <option value="6">Other</option>
                        </select></div>
                </div>

                <div class="tr">
                    <div class="td right">Facial hair:</div>
                    <div class="td"><input type="text" name="susFacialHair" value="N/A"></div>
                    <div class="td right">Complexion:</div>
                    <div class="td"><select name="susComplexion">
                            <option value="3">Unknown</option>
                            <option value="1">Dark</option>
                            <option value="2">Light</option>
                        </select></div>
                    <div class="td right">Teeth:</div>
                    <div class="td"><input type="text" name="susTeeth" value="N/A"></div>
                </div>

                <div class="tr">
                    <div class="td right">Scars, Marks, Tattoos (Describe):</div>
                    <div class="td"><textarea name="susScarsEtc" rows="5" cols="18" onclick="this.select()">Nothing notable.</textarea></div>
                    <div class="td right">General Appearance (Describe):</div>
                    <div class="td"><textarea name="susGenAppear" rows="5" cols="18" onclick="this.select()">Nothing notable.</textarea></div>
                    <div class="td right">Distinguishing Handicap(s) (Describe):</div>
                    <div class="td"><textarea name="susHandicap" rows="5" cols="18" onclick="this.select()">Nothing notable.</textarea></div>
                </div>

                <div class="tr">
                    <div class="td right">Street:</div>
                    <div class="td"><input type="text" name="susAddrStreet"></div>
                    <div class="td right">City:</div>
                    <div class="td"><input type="text" name="susAddrCity"></div>
                    <div class="td right">State:</div>
                    <!--                                        <div class="td"><input type="text" name="susAddrState"></div>-->
                    <div class="td"><select name="susAddrState">

                            <?php
                            foreach ($us_state_abbrevs_names as $key => $value) {
                                ?>
                                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>

                            <?php }
                            ?>
                        </select></div>


                </div>


                <div class="tr">
                    <div class="td right">Phone:</div>
                    <div class="td"><input type="text" id="phone" name="susPhone"></div>
                    <div class="td right">Occupation:</div>
                    <div class="td"><input type="text" name="susOccupation" value="unknown"></div>
                    <div class="td right">Current Location (at time of call):</div>
                    <div class="td"><input type="text" name="susCurrentLoc" value="unknown"></div>
                </div>


                <div class="tr">
                    <div class="td right">Is Suspect armed?</div>
                    <div class="td"><select name="susArmed">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>

                    <div class="td right">Type of weapon:</div>
                    <div class="td"><select name="weaType">
                            <option value="N/A">N/A</option>
                            <option value="knife">Knife</option>
                            <option value="handgun">Handgun</option>
                            <option value="rifle">Rifle</option>
                            <option value="shotgun">Shotgun</option>
                            <option value="explosives">Explosives</option>
                        </select></div>

                    <div class="td right">Caliber:</div>
                    <div class="td"><input type="text" name="caliber" value="N/A"></div>
                </div>
            </fieldset>
            <fieldset class="table">
                <legend>Witness Info</legend>
                <div class="tr">
                    <div class="td right">First Name:</div>
                    <div class="td"><input type="text" name="witFirstName"></div>
                    <div class="td right">Last Name:</div>
                    <div class="td"><input type="text" size="25" name="witLastName"></div>
                    <div class="td right">Phone:</div>
                    <div class="td"><input type="text" name="witPhone"></div>
                </div>
            </fieldset>


            <fieldset class="table">
                <legend>Loc Info</legend>
                <div class="tr">

                    <div class="td right">Narcotic Activity at location?</div>
                    <div class="td"><select name="locNarcActivity">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>

                    <div class="td right">Location of incident (car, street corner, building, etc.):</div>
                    <div class="td"><input type="text" name="locType"></div>
                    <div class="td right">Number of Floors:</div>
                    <div class="td"><input type="text" name="locNumFloors"></div>
                </div>

                <div class="tr">

                    <div class="td right">Color of building:</div>
                    <div class="td"><input type="text" name="locBuildColor"></div>
                    <div class="td right">Apartment #:</div>
                    <div class="td"><input type="text" name="locAptNum"></div>
                    <div class="td right">Telephone #:</div>
                    <div class="td"><input type="text" name="locPhNum"></div>
                </div>
                <div class="tr">
                    <div class="td right">Surveillance?</div>
                    <div class="td"><select name="locSurveillance">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>
                </div>
                <div class="tr">

                    <div class="td right">Dog?</div>
                    <div class="td"><select name="locDogYesOrNo">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>
                    <div class="td right">Dog inside or outside?</div>
                    <div class="td"><select name="locDogInOrOut">
                            <option value="4">N/A</option>
                            <option value="1">Inside</option>
                            <option value="2">Outside</option>
                            <option value="3">Both</option>
                        </select></div>

                    <div class="td right">Dog size:</div>
                    <div class="td"><select name="locDogSize">
                            <option value="4">N/A</option>
                            <option value="1">Small</option>
                            <option value="2">Medium</option>
                            <option value="3">Large</option>
                            <option value="5">Big</option>
                        </select></div>
                </div>

                <div class="tr">

                    <div class="td right">Dog breed (if known):</div>
                    <div class="td"><input type="text" name="locDogBreed"></div>

                    <div class="td right">Is the dog mean?</div>
                    <div class="td"><select name="locDogMean">
                            <option value="4">N/A</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                            <option value="3">Unknown</option>
                        </select></div>

                </div>

                <div class="tr">

                    <div class="td right">Are there children at the location?</div>
                    <div class="td"><select name="locKids">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>
                        </select></div>

                    <div class="td right">If there are children, how old are they?</div>
                    <div class="td"><input type="text" name="locKidAge"></div>

                </div>
            </fieldset>


            <fieldset class="table">
                <legend>Vehicle Information:</legend>

                <div class="tr">
                    <div class="td right">Does the vehicle belong to the suspect?</div>
                    <div class="td"><select name="vehIsSus">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>

                        </select></div>

                    <div class="td right">Is the vehicle stolen?</div>
                    <div class="td"><select name="vehIsStolen">
                            <option value="3">Unknown</option>
                            <option value="1">Yes</option>
                            <option value="2">No</option>

                        </select></div>

                    <div class="td right">If the vehicle is stolen, from where:</div>
                    <div class="td"><input type="text" name="vehStolLoc" value="N/A"></div>
                </div>


                <div class="tr">

                    <div class="td right">Vehicle Year:</div>
                    <div class="td"><select name="vehYear">
                            <?php
                            foreach ($veh_year_array as $item) {
                                ?>
                                <option value="<?php echo $item; ?>"><?php echo $item; ?></option>
                            <?php }
                            ?>


                        </select></div>
                    <div class="td right">Make:</div>
                    <!--                                        <div class="td"><input type="text" name="vehMake"></div>-->
                    <div class="td"><select name="vehMake">
                            <?php
                            foreach ($us_car_makes as $key => $value) {
                                ?>
                                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                                <!--<option value="--><?php //echo $value['name'];
                                ?><!--">--><?php //echo $value['name'];
                                ?><!--</option>-->
                            <?php }
                            ?>
                        </select></div>
                    <div class="td right">Model:</div>
                    <div class="td"><input type="text" name="vehModel"></div>
                </div>
                <div class="tr">

                    <div class="td right">Size (compact car, sedan, etc.):</div>
                    <div class="td"><input type="text" name="vehSize"></div>
                    <div class="td right">Num doors:</div>
                    <div class="td"><input type="text" name="vehNumDoors"></div>
                </div>


                <div class="tr">

                    <div class="td right">Color(top):</div>
                    <div class="td"><input type="text" name="vehColTop"></div>
                    <div class="td right">Color(middle):</div>
                    <div class="td"><input type="text" name="vehColMid" value="same"></div>
                    <div class="td right">Color(bottom):</div>
                    <div class="td"><input type="text" name="vehColBot" value="same"></div>

                </div>

                <div class="tr">


                    <div class="td right">Distinguishing feature(s):</div>
                    <div class="td"><input type="text" name="vehDistFeat"></div>

                </div>

                <div class="tr">

                    <div class="td">Vehicle License Info:</div>
                </div>
                <div class="tr">
                    <div class="td right">Number:</div>
                    <div class="td"><input type="text" name="vehLicNum"></div>
                    <div class="td right">State:</div>
                    <!--                                        <div class="td"><input type="text" name="vehLicState"></div>-->
                    <div class="td"><select name="vehLicState">



                            <?php
                            foreach ($us_state_abbrevs_names as $key => $value) {
                                ?>
                                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>

                            <?php }
                            ?>

                        </select></div>

                    <div class="td"><select name="vehLicState">

                            <?php
                            foreach ($us_state_abbrevs_names as $key => $value) {
                                ?>
                                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>

                            <?php }
                            ?>
                        </select></div>

                    <div class="td right">Year:</div>
                    <div class="td"><select name="vehLicYear">
                            <?php
                            foreach ($veh_year_array as $item) {
                                ?>
                                <option value="<?php echo $item; ?>"><?php echo $item; ?></option>
                            <?php }
                            ?>


                        </select></div>
                </div>
            </fieldset>
            <fieldset>
                <legend>Summary of Information:</legend>


                <textarea name="crimeSumOfInfo" rows="13" cols="94" onclick="this.select()">Enter notes here</textarea>

            </fieldset>

            <input type="submit" name='submitViolentCrimeData' value='Submit report'/>
<!--            <input type="submit" name='submitViolentCrimeData' value='Submit report'/>-->


        </form>
    </div>
    <div align="center">
        <form class="formLayout" method="POST" action="SearchCase.php">
            <input type="submit" value="View Report">
        </form>
    </div>

1 个答案:

答案 0 :(得分:0)

好的,只是意识到该页面正在提交&#39;因为我使用的是按钮元素。改变它来照顾它。很抱歉没有脑子的帖子。我应该删除这个问题吗?