简体   繁体   English

如何使用jQuery将值从一页传递到另一页?

[英]How to pass value from one page to another page using jQuery?

I am new to jQuery. 我是jQuery新手。 I want to pass value from one page to another page using jQuery. 我想使用jQuery将值从一页传递到另一页。 I have also javascript code for passing this value. 我也有JavaScript代码用于传递此值。 But I want to do the same things using jQuery. 但是我想使用jQuery做同样的事情。

My php and Javascript code is as below 我的PHP和JavaScript代码如下

PHP Code: PHP代码:

          <?php
            for ($i=1; $i<count($array)+1; $i++) {
          ?>
            <tr>
              <td><?php print_s($array[$i]['open_date']); ?></td>

              <td style="width: 120px" ><?php print_s($array[$i]['group']); ?></td>
              <td style="width: 150px" ><?php print_s($array[$i]['division']); ?></td>
              <td style="width:  30px" ><?php print_s($array[$i]['control_no_parent']); ?>
                <input type="hidden" name="group[<?php print_s($i); ?>]"             id="group[<?php print_s($i); ?>]"             value="<?php print_s($array[$i]['group']); ?>" />
                <input type="hidden" name="division[<?php print_s($i); ?>]"          id="division[<?php print_s($i); ?>]"          value="<?php print_s($array[$i]['division']); ?>" />
                <input type="hidden" name="control_no_parent[<?php print_s($i); ?>]" id="control_no_parent[<?php print_s($i); ?>]" value="<?php print_s($array[$i]['control_no_parent']); ?>" />
              </td>
              <td>
                <?php print_s($array[$i]['control_no_child']); ?>
                <input type="hidden" name="control_no_child[<?php print_s($i); ?>]"  id="control_no_child[<?php print_s($i); ?>]"  value="<?php print_s($array[$i]['control_no_child']); ?>" />
              </td>
              <td><?php print_s($array[$i]['title']); ?></td>
              <td><input type="submit" name="disp_btn[<?php print_s($i); ?>]" class="w50" value="表 示" onClick = "tekeOver(<?php print_s($i); ?>)"/></td>
            </tr>
          <?php
            }
          ?>

Javascript Code: JavaScript代码:

function tekeOver(RowNo) {

  document.getElementById('RowNo').value             = RowNo
  document.getElementById('group').value             = document.getElementById('group[' + RowNo + ']').value
  document.getElementById('division').value          = document.getElementById('division[' + RowNo + ']').value
  document.getElementById('control_no_parent').value = document.getElementById('control_no_parent[' + RowNo + ']').value
  document.getElementById('control_no_child').value  = document.getElementById('control_no_child[' + RowNo + ']').value
}

In my opinion,we have some ways. 我认为,我们有一些方法。 Firstly, we can use cookie if we don't care the suporting of the browser. 首先,如果我们不关心浏览器的支持,我们可以使用cookie。 The first page: 第一页:

$.cookie('the_cookie', 'the_value');

Another page: 另一页:

$.cookie('the_cookie');

Of course, we need jquery plugin jquery.cookie.js What's more, we can transfer value in url. 当然,我们需要jquery插件jquery.cookie.js而且,我们可以在url中传递值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM