0

在下面的代码中,我在搜索之前搜索数据,我的 url 将在 coursemaster_site 中,当我搜索时,它将在 coursemaster_site/index1 中,当我关闭搜索结果时,url 将在 coursemaster_site /coursemaster_site 但我希望 url 在coursemaster_site 关闭搜索结果后。

控制器:coursemaster_site

function index1()
    {
        $data            = array();
        $keyword         = $this->input->post('keyword');
        if($keyword!=""){
            $data['results'] = $this->coursemaster_model->search($keyword);
        }
        $this->load->view('coursemaster_view', $data);

    }

视图:coursemaster_view

<form action="<?php echo site_url('coursemaster_site/index1');?>" method = "post">
<br/><center>SEARCH:<input type="text" name = "keyword" required/>
<input type="submit" name="submit" id="opn" value = "Search"  onClick="hide1('hiddendiv')"  class="btn-success btn" /></center>
</form>

<?php
if (isset($_POST['submit'])) { // Here
  // Do the search here
        if($results){
         ?> <div id='hideme'>
         CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>
        <img  src="<?php echo base_url('img/close.png'); ?>" width="15" height="15" alt="Close"    onClick="hide('hideme')"/>
        </a><div style="background:#FFFFFF; width:1000px; height: 540px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -120px" id="modal"  >
       <table class="display2 table table-bordered table-striped" id='results'>
       <tr>
            <th>course_code</th>
            <th>course name</th>
       </tr>
       <tr><?php
             foreach ($results as $row) {
      ?>
       <td><?php echo $row->course_code;?></td>
       <td><?php echo $row->course_name;?></td>
       </tr>
            <?php
            } 
        }else{
        echo"<div id='hideme'>
         CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>";
        echo "<div id='modal' style='background:#FFFFFF; width:1000px; height: 525px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -110px'>";
        }
  echo"no results";
  echo'</div>';
echo '</div>';        }
 // If closing
?>
</table>
</div></div>
<script>
$('a.modal').bind('click', function(event) { 
        event.preventDefault();
        $('#modal').fadeIn(10);

    });
    function hide(obj) {
        var el = document.getElementById(obj);
        el.style.display = 'none';
    }
    function hide1(obj) {
        var el = document.getElementById(obj);
        el.style.display = 'none';
    }
    </script>
4

2 回答 2

0

进行以下更改并检查它是否有效:

<div id='hideme'>
     CLOSE<a href='javascript:void(0);' class='close_notification' title='Click to Close'>";
于 2013-09-17T08:10:51.310 回答
0

改成:

<div id='hideme'>CLOSE
 <a href='/coursemaster_site' class='close_notification' title='Click to Close'> 
...

在这两个地方。前导斜杠使 href 从根目录开始。

于 2013-09-17T08:19:47.507 回答