通过选择底部 Div 中的链接来重新加载顶部 Div(需要独立运行)
我希望你能帮我解决这个问题!
我有一个 movieContents.php 文件,其中包含电影详细信息(标题、导演、年份),作为名为 $films 的数组的项目。
它看起来像这样:
<?php
$films = array(
'movieOne' => array(
'title' => array(
'en'=>'Movie ONE',
'es'=>'PELICULA UNO'
),
'director' => 'John Doe 1',
'year' => '2011'
),
'movieTwo' => array(
'title' => array(
'en'=>'Movie TWO',
'es'=>'PELICULA DOS'
),
'director' => 'John Doe 2',
'year' => '2010'
),
'movieThree' => array(
'title' => array(
'en'=>'Movie THREE',
'es'=>'PELICULA TRES'
),
'director' => 'John Doe 3',
'year' => '2009'
),
'movieFour' => array(
'title' => array(
'en'=>'Movie Four',
'es'=>'PELICULA CUATRO'
),
'director' => 'John Doe 4',
'year' => '2008'
),
'movieFive' => array(
'title' => array(
'en'=>'Movie FIVE',
'es'=>'PELICULA CINCO'
),
'director' => 'John Doe 5',
'year' => '2007'
),
'movieSix' => array(
'title' => array(
'en'=>'Movie SIX',
'es'=>'PELICULA SEIS'
),
'director' => 'John Doe 6',
'year' => '2007'
)
);
?>
我想做的是:
拥有一个带有主顶部 Div 的页面,其中显示其中一部电影的详细信息,以及底部滚动 Div,其中我有要显示在上面的每部电影的链接顶级部门
我可以完美地做到这一点,但是...当我的底部滚动 Div 上有 15 部电影时,我单击右侧的最后一部电影,它会加载整个页面,因此底部滚动 Div 不会停留在与那是当我点击最后一部电影的链接时,如果没有转到底部滚动 Div 的开头。
这是我的films.php 文件:
<?php include_once("filmsContent.php");
@$film = $_REQUEST['title'];
?>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
</head>
<body>
<?php
echo "<div class='content'>"; ?>
<div class='films'>
<?php echo $films[$film]['title']['en']."<br />";
echo $films[$film]['director']."<br />";
echo $films[$film]['year']."<br />";
?>
</div>
<div style='width: 200px; height: 60px; overflow: auto; overflow-y: hidden;'>
<div style='width: 700px;'>
<?php
foreach($films as $film=>$attribute)
{
echo "<a href='?title=".$film."'>".$films[$film]['title']['en']."</a> | ";
}
?>
</div>
</div>
</div>
</body>
</html>
我希望每次都用我选择的电影信息重新加载顶部 Div,并且只有该 Div,而不是整个页面,这样底部滚动 Div 的行为将独立于顶级部门
我想避免使用 Iframe 或对象。我相信我需要使用 JQuery、AJAX,但我不知道如何使其工作。我花了几个小时寻找解决方案,但没有成功。
你能帮我一下吗?
谢谢!
I hope you can help me with this one!
I have a filmsContents.php file with movies details (title, director, year) located as items of an array called $films.
It looks like this:
<?php
$films = array(
'movieOne' => array(
'title' => array(
'en'=>'Movie ONE',
'es'=>'PELICULA UNO'
),
'director' => 'John Doe 1',
'year' => '2011'
),
'movieTwo' => array(
'title' => array(
'en'=>'Movie TWO',
'es'=>'PELICULA DOS'
),
'director' => 'John Doe 2',
'year' => '2010'
),
'movieThree' => array(
'title' => array(
'en'=>'Movie THREE',
'es'=>'PELICULA TRES'
),
'director' => 'John Doe 3',
'year' => '2009'
),
'movieFour' => array(
'title' => array(
'en'=>'Movie Four',
'es'=>'PELICULA CUATRO'
),
'director' => 'John Doe 4',
'year' => '2008'
),
'movieFive' => array(
'title' => array(
'en'=>'Movie FIVE',
'es'=>'PELICULA CINCO'
),
'director' => 'John Doe 5',
'year' => '2007'
),
'movieSix' => array(
'title' => array(
'en'=>'Movie SIX',
'es'=>'PELICULA SEIS'
),
'director' => 'John Doe 6',
'year' => '2007'
)
);
?>
what I would like to do is:
To have a page with a Main top Div where details of one of the movies are displayed, and a bottom scrolling Div where I have the links for each movie to be displayed on the top Div.
I could do this perfectly BUT... When I have 15 movies on my bottom scrolling Div, and I click the last movie on the right, it loads the whole page, so the bottom scrolling Div doesn't stay in the same place where it was when I clicked on the link of the last movie, if not goes to the beginning of that bottom scrolling Div.
This is my films.php file:
<?php include_once("filmsContent.php");
@$film = $_REQUEST['title'];
?>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
</head>
<body>
<?php
echo "<div class='content'>"; ?>
<div class='films'>
<?php echo $films[$film]['title']['en']."<br />";
echo $films[$film]['director']."<br />";
echo $films[$film]['year']."<br />";
?>
</div>
<div style='width: 200px; height: 60px; overflow: auto; overflow-y: hidden;'>
<div style='width: 700px;'>
<?php
foreach($films as $film=>$attribute)
{
echo "<a href='?title=".$film."'>".$films[$film]['title']['en']."</a> | ";
}
?>
</div>
</div>
</div>
</body>
</html>
What I wish is to have the Top Div reloaded with the info of the movie I choose every time, and only that Div, not the entire page, that way the bottom scrolling Div will behave independently of the Top Div.
I want to avoid Iframes or Objects. I believe I need to use JQuery, AJAX, but I don't know how to make it work. I've been searching for hours to find the solution for this and I had no luck.
Could you help me please?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你需要使用某种类型的“Carousel”jquery插件(谷歌有很多)
这是一个
http://jqueryfordesigners.com/demo/infinite-carousel.html
这里还有更多
http://www.tripwiremagazine.com/2011/06/jquery-carousel.html
What I believe you need to use is some type of 'Carousel' jquery plugin ( google there are so many )
Here is one
http://jqueryfordesigners.com/demo/infinite-carousel.html
here is some more
http://www.tripwiremagazine.com/2011/06/jquery-carousel.html