简体   繁体   English

单击后向下滚动文本

[英]Scroll text down after clicking

I am having difficulties in the following problem: 我在以下问题上遇到困难:

I have a screen in PHP which displays a list of some records when I choose any of these records (by clicking) it gives me a web site to share the data with this record. 我在PHP中有一个屏幕,当我选择任何一条记录(通过单击)时会显示一些记录的列表,它为我提供了一个与该记录共享数据的网站。 So far, it works. 到目前为止,它仍然有效。

I need to click on some of these records, instead of him open another page, scroll down the screen and the record data to appear in the same screen, ie without opening another window. 我需要单击其中一些记录,而不是他打开另一个页面,向下滚动屏幕,然后记录数据显示在同一屏幕上,即无需打开另一个窗口。

Do you have any idea how to do this? 你有什么想法吗?

Thanks 谢谢

You'll need to have a DIV at the bottom of the page, which will be completed by using an Ajax call and some javascript or jquery. 您需要在页面底部具有DIV,这将通过使用Ajax调用和一些javascript或jquery完成。

Without going into too much detail, heres what needs to happen: 无需赘述,这里需要发生的事情:

  1. User clicks a link which fires off an ajax request. 用户单击一个链接,该链接将触发ajax请求。
  2. The backend PHP script takes the ajax call and generates either XML or pure HTML and returns the data. 后端PHP脚本接受ajax调用并生成XML或纯HTML并返回数据。
  3. JQuery or JavaScript on the original page takes the return and populates the empty DIV at the bottom of the page. 原始页面上的JQuery或JavaScript获取返回值,并在页面底部填充空DIV。

Regards 问候

It sounds like you'll need to use ajax to pull this off. 听起来您需要使用Ajax才能实现此目的。

I would personally suggest starting with reading up on the jQuery javascript library if you are not familiar with it already. 我个人建议,如果您还不熟悉它,请从jQuery JavaScript库开始阅读。 It provides a very good set of ajax tools to work with. 它提供了非常好的ajax工具集。

Create a DIV layer on the bottom of the page. 在页面底部创建DIV层。 Use a simple AJAX library like this 使用像这样的简单AJAX库

Create a new php page that will only load a new record based on the recordID and call this page on the onclick method of your link that is now opening in the new window 创建一个新的php页面,该页面将仅基于recordID加载新记录,并在链接的onclick方法上调用此页面,该链接现在在新窗口中打开

I would try adding some jQuery to your page to handle this effect. 我会尝试向您的页面添加一些jQuery以处理这种效果。 If you do add jQuery here is a function written to do just that: 如果您确实添加了jQuery,那么这里编写的函数就是这样做的:

http://pastebin.com/SeMHwSgg http://pastebin.com/SeMHwSgg

Call the script like so: Where a is the record you are having them click on and href="[some anchor]" located at the spot on the screen where you want the scrolling to stop: 像这样调用脚本: a是您要让他们记录的记录,然后单击href="[some anchor]"位于屏幕上要停止滚动的位置:

<a id="gotop" href="#" onclick="goTop();return false;">click here</a>

So 所以

Indeed, there is no error, it just does not have the effect that (scroll down the screen and show the record data). 确实,没有错误,只是没有效果(向下滚动屏幕并显示记录数据)。 For now, it only shows the record open in another window. 目前,它仅显示在另一个窗口中打开的记录。

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

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