不在新标签中显示表单

时间:2015-03-09 09:04:55

标签: html

我有一个页面principal.phpmain.php。当我单击主要部分时,它会在新选项卡中打开主体表单。我不想要它。我想在主要部分显示表格。我怎么能这样做?

main.php

<html>
<head>
       <title>e-Statistics</title>
<style>
  .body{
      margin: 0;

  }

  .nav{
      width: 115%;
      height:40px;
      background:black;
     text-align:center;
  }
   .nav ul{
     width: 800px;
     margin:0 auto;
     padding:0;
  }
   .nav ul li{
     list-style: none;

   }
   .nav ul li a{
      float: left;
      text-decoration:none;
      display:block;
      padding:10px 40px;
      color:#ff9933 ;
      border-right:1px solid #ccc;
   }
   .nav ul li a:hover{
      color:white;

   }
</style>
</head>
<body>

    <div class="nav">
    <ul>

        <li><a href="principal.php">Principal</a></li>
        <li><a href="acad_director.php">Academic Director</a></li>
        <li><a href="lecturer.php">Lecturer</a></li>

    </ul>
    </div>
  </div>
 </div>
</body>
</html>

 principal.php

    <?php

       if ($_SERVER['REQUEST_METHOD'] == 'POST') {
       switch ($_POST['program']) {
       case 'Computer Science':
       include 'csreadprog.php';
       break;
       }   
       exit;
      }   
    ?>

     <html>
     <body>
        <form method="POST">
        <b>Programs:<b/>
        <select name="program"> 
        <option value="Choose">Please select..</option>
        <option value="Computer Science">Computer Science</option> 
        <option value="BAED">BAED</option>
        <option value="Psychology">Psychology</option>
        <option value="English Studies">English Studies</option></select><br/><br/>

        <b>Year:<b/>
        <select name="year"> 
        <option value="Choose">Please select..</option>
        <option value="2007">2007</option> 
        <option value="2008">2008</option>
        <option value="2009">2009</option>
        <option value="2010">2010</option>
        <option value="2011">2011</option>
        <option value="2012">2012</option>
        <option value="2013">2013</option>
        <option value="2014">2014</option></select><br/><br/>

        <b>Services:<b/>
        <select name="services"> 
        <option value="Choose">Please select..</option>
        <option value="Library">Library</option> 
        <option value="IT Facilities">IT Facilities</option>
        <option value="IT Services">IT Services</option>
        <option value="Services and Support">Services and Support</option>
        <option value="Clubs and Societies">Clubs and Societies</option>
        <option value="Other facilities ">Other facilities</option></select> <br/><br/>

    <br/>
        <input type="submit" name="submit" value="Submit">
     </form>
   </body>
 </html>

3 个答案:

答案 0 :(得分:2)

<a href="http://www.stackoverflow.com" target="_self">Open it on same page</a>

使用此代码定位同一页面上的超链接。希望这有帮助。

答案 1 :(得分:1)

这可能是浏览器问题......

但只是...... ...

<a href="principal.php" target="_self">Principal</a>

只需添加target="_self"

答案 2 :(得分:1)

据我所知,您希望在每个页面上显示导航栏。

解决方案是在head标签中添加样式代码,并在main.php中添加样式中的导航栏列表

您的代码可能如下所示......

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    switch ($_POST['program']){

    case 'BSc Computer Science':
        include 'csreadprog.php';
        break;
    case 'BSc Psychology':
        include 'psyreadprog.php';
        break;
    case 'BA Business Administration':
        include 'baedreadprog.php';
        break;
    }

    switch ($_POST['services']){

    case 'Library':
        include 'libraryread.php';
        break;

    case 'IT Services and Facilities':
        include'itserviceread.php';
        break;

    case 'Front Desk':
        include'frontdeskread.php';
        break;

    case 'Course Administrator':
        include'courseadminread.php';
        break;

    case 'International Student Office':
        include'stofficeread.php';
        break;

    case 'Clubs and Societies':
        include'clubsread.php';
        break;
    }

    switch($_POST['program'] && $_POST['criteria']){

    case 'BSc Computer Science' && 'I have found the unit interesting':
      include 'readcsprogcrit.php';
      break;

    case 'BSc Psychology' && 'I have gained knowledge':
      include 'readpsyprogcrit.php';
      break;

    case 'BA Business Administration' && 'I have acquired skills':
      include 'readbaedprogcrit.php';
      break;

    }

    exit;
}   
?>

<html>
<head>

<style>
    .body{
        margin: 0;

    }

    .nav{
        width: 115%;
        height:40px;
        background:black;
        text-align:center;
    }
    .nav ul{
        width: 800px;
        margin:0 auto;
        padding:0;
    }
    .nav ul li{
        list-style: none;

    }
    .nav ul li a{
        float: left;
        text-decoration:none;
        display:block;
        padding:10px 40px;
        color:#ff9933 ;
        border-right:1px solid #ccc;
    }
    .nav ul li a:hover{
        color:white;

    }
    </style>


</head>
<body>

<div class="nav">
        <ul>

            <li><a href="principal.php">Principal</a></li>
            <li><a href="acad_director.php">Academic Director</a></li>
            <li><a href="lecturer.php">Lecturer</a></li>

        </ul>
</div>

    <form method="POST" action="principal.php">
    <b>Programs:<b/>
    <select name="program"> 
    <option value="Choose">Please select..</option>
    <option value="Computer Science"> BSc Computer Science</option> 
    <option value="BAED">BA Business Administration</option>
    <option value="Psychology">BSc Psychology</option></select><br/><br/>

    <b>Departments:<b/>
    <select name="department"> 
    <option value="Choose">Please select..</option>
    <option value="Computer Science">Computer Science</option> 
    <option value="BAED">BAED</option>
    <option value="Psychology">Psychology</option></select><br/><br/>

    <b>Year:<b/>
    <select name="year"> 
    <option value="Choose">Please select..</option>
    <option value="2005">2005</option> 
    <option value="2006">2006</option>
    <option value="2007">2007</option>
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option value="2010">2010</option></select><br/><br/>

    <b>Criteria:<b/>
    <select name="criteria"> 
    <option value="Choose">Please select..</option>
    <option value="I have found the unit interesting">I have found the unit interesting</option> 
    <option value="I have gained knowledge">I have gained knowledge</option>
    <option value="I have acquired skills">I have acquired skills</option>
    <option value="Useful other resources">Useful other resources</option></select><br/><br/>

    <b>Services:<b/>
    <select name="services"> 
    <option value="Choose">Please select..</option>
    <option value="Library">Library</option> 
    <option value="Course Administrator">Course Administrator</option>
    <option value="International Student Office">International Student Office</option>
    <option value="IT Services and Facilities">IT Services and Facilities</option>
    <option value="Front Desk">Front Desk</option>
    <option value="Clubs and Societies">Clubs and Societies</option></select><br/><br/>

    <br/>
    <input type="submit" name="submit" value="Submit">
    </form>
</body>
</html>