如何在提交表单后使标签保留在当前选项卡中?

时间:2015-02-09 11:09:43

标签: xhtml

我在tab中有3个提交表单。提交表单后,它会成功显示消息注册。但它转到主页,所以只有在单击特定选项卡后,我才能看到该消息。我想在提交表单后让标签保留在当前标签中。

<div class="tabs">
<form id="target">
    <ul class="tab-links">
        <li ><a href="#tab1" id="tabs-A" >Incident Report</a></li>
        <li><a href="#tab2"  id="tabs-B">Death Report</a></li>
        <li><a href="#tab3" id="tabs-C" >Negative Case Data</a></li>
     </ul>
      <div class="tab-content">
        <div id="tab1" class="tab  ">
    <p>

        <?php

        include("Report1.php");

         ?>

         </p>
 </div>     
   <div id="tab2" class="tab">
  <p>
        <?php

        include("Report2.php");
         ?>
        </p>

    </div>
     <div id="tab3" class="tab">
  <p>
        <?php
        include("Report3.php");
         ?>
         </p>

    </div>
     </div>
     </form>
</div>  

这是我的jquery:

<script>
jQuery(document).ready(function() {



    jQuery('.tabs .tab-links a').on('click', function(e)  {
        var currentAttrValue = jQuery(this).attr('href');

        // Show/Hide Tabs
        jQuery('.tabs ' + currentAttrValue).show().siblings().hide();

        // Change/remove current tab to active
        jQuery(this).parent('li').addClass('active').siblings().removeClass('active');

        e.preventDefault();
    });
</script>

这是我的Report1.php。

<?php

include_once 'dataAccessControl.php';
$DataAccessController = new DataAccessController();
if (isset($_POST['report1'])) 
 {
    $daydropdown111=$_POST['daydropdown111'];
    $monthdropdown111=$_POST['monthdropdown111'];
    $yeardropdown111=$_POST['yeardropdown111'];
    $dreport_place=$_POST['dreport_place'];
    $dreport_address=$_POST['dreport_address'];
    $dreport_additional=$_POST['dreport_additional'];
 }
 else 
 {
    $daydropdown111="";
    $monthdropdown111="";
    $yeardropdown111="";
    $dreport_place ="";
    $dreport_address="";
    $dreport_additional="";
 }

if (isset($_POST['report1'])) 
{
    $death = $DataAccessController->death_reports($_POST['daydropdown111'],$_POST['monthdropdown111'],$_POST['yeardropdown111'],$_POST['dreport_place'], $_POST['dreport_address'], $_POST['dreport_additional']);
    if ($death) {
          echo"<p><font  color=red  size='5pt' > Your  Report has been Registered</font></p>";
        //header("Refresh:3;url='deathReport.php'");
        } 
}
?>

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Death Report</title>  

<script type="text/javascript">

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield)
{

   var today=new Date()
   var dayfield=document.getElementById(dayfield)
   var monthfield=document.getElementById(monthfield)
   var yearfield=document.getElementById(yearfield)
    for (var i=0; i<=31; i++)
   dayfield.options[i-1]=new Option(i, i)
   dayfield.options[today.getDate()-1]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
   for (var m=0; m<12; m++)
   monthfield.options[m]=new Option(monthtext[m], monthtext[m])
   monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
   var thisyear=1999
   for (var y=0; y<45; y++){
   yearfield.options[y]=new Option(thisyear, thisyear)
   thisyear+=1
   }
   yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}
</script>
</head>

<body >
<div id="color" >
    <table>

            <h1 align="center"><p>Death Report</h1>


    <form action="" method="POST">
        <tr><td>Date </td><td>
            <select name="daydropdown111" id="daydropdown111"></select> 
            <select name="monthdropdown111" id="monthdropdown111"></select>
            <select name="yeardropdown111" id="yeardropdown111"></select>
            <script type="text/javascript">
            //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)

                    populatedropdown("daydropdown111", "monthdropdown111", "yeardropdown111")

            </script>

        </td></tr>

        <tr><td></br>  Place of  </td><td></br><select name="dreport_place"id="wgtmsr">
        <option value="hospital" >Hospital</option><option value="residence">Residence</option><option value="others">Others</option></select></td></tr>

        <tr><td>Address  </td><td></br><textarea name="dreport_address" rows="5" cols="32" id="loc" value=""> </textarea></td></tr>

        <tr><td>Additional Cases if any</td><td></br> <textarea name="dreport_additional" rows="5" cols="32" id="loc" value=""> </textarea></td></tr></label></td></tr>

        <tr><td></td><td><input type="submit" name="report1" value="Save" id="btnsize"  /></td></tr>

    </form>
    </table></br>
</div>


</body>
</html>

0 个答案:

没有答案