[英]get selected item on redirected page — how?
Our site's UI displays read-only text fields which have mouse-click handlers -- when the user clicks one of the read-only fields, we change its CSS to make the text and background color of that item appear "selected." 我们网站的UI显示具有鼠标单击处理程序的只读文本字段-当用户单击其中一个只读字段时,我们更改其CSS,以使该项目的文本和背景颜色显示为“选定”。
If the user clicks a 'show item' button on this same page, the next page needs to 'know' which item was selected on the page that it was redirected from. 如果用户在同一页面上单击“显示项目”按钮,则下一页需要“知道”在页面上从哪个项目中选择了重定向项。
PAGE A: user clicks a read-only field to select it; 页面A:用户单击一个只读字段将其选中; the selection is highlighted via CSS .........and user can click a 'Show Item' button on this page to see the details of the selected item -- we redirect to Page B to show the selected item's details.
选中的内容通过CSS突出显示.............用户可以单击此页面上的“显示项目”按钮以查看所选项目的详细信息-我们重定向到页面B以显示所选项目的详细信息。 The 'Show item' will NOT be a form 'submit' button, just a standard button.
“显示项目”将不是表单“提交”按钮,而只是标准按钮。
PAGE B: Gets redirected to. PAGE B:被重定向到。 Needs to know what item on Page A was the selected item (using the item's ID or value etc.)
需要知道页面A上的哪个项目是所选项目(使用该项目的ID或值等)
How? 怎么样? If you are inclined to say 'Ajax' don't bother, I do not have that in my allowed suite of options, nor jquery, those are my marching orders.
如果您倾向于说“ Ajax”不要打扰,那么我在允许的选项集或jQuery中都没有这些,这就是我的前进顺序。
The onclick handler is client-side code on Page A. The redirection is via window.location="page2.php" onclick处理程序是页面A上的客户端代码。重定向通过window.location =“ page2.php”
I do not see any way that Page A can make Page B aware of the selected item's name or ID or etc. -- it's not a form post, it's all client side code. 我看不到页面A可以使页面B知道所选项目的名称或ID等的任何方式。它不是表单发布,而是所有客户端代码。
Although I might be missing something, pls let me know if I am. 尽管我可能会缺少一些东西,但请让我知道我是否。 I'm stuck right now.
我现在被困住了。
Reaching for straws, I thought of calling submit() but I don't think I can pass anything that way that would allow Page B to know which item on Page A was selected, besides the fact that submit() requires A-Form.submit() and the 'Show Item' button is not on a form on Page A. 伸手去拿秸秆,我想调用submit(),但我认为我无法通过任何方式允许Page B知道选择了Page A上的哪个项目,除了submit()需要A-Form的事实。 Submit()和“显示项”按钮不在页面A的表单上。
capture the click event and return the target's id. 捕获点击事件并返回目标的ID。 pass the target's id as a url param on the redirect.
在重定向上将目标的ID作为url参数传递。
when redirecting just append required information with #
prefix like this : window.location="page2.php#1,2,3,4"
and then on the page2 parse those values using JS. 重定向时,只需在所需的信息后加上
#
前缀即可: window.location="page2.php#1,2,3,4"
,然后在page2上使用JS解析这些值。
you can access values you have passed by window.location.hash
in JS 您可以访问JS中
window.location.hash
传递的值
In your onclick event handler, execute an ajax request to your server that performs something like 在您的onclick事件处理程序中,向服务器执行一个执行以下操作的ajax请求:
<?
session_start();
$_SESSION['selectedVariable'] = intval($_GET['foo']);
?>
Next page load, your site will know, as it is stored in the session. 您的网站将知道下一页加载,因为它存储在会话中。
Of course, this won't work really well with multiple tabs. 当然,使用多个选项卡不能很好地工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.