如何创建“转到页面” PHP 中的下拉列表?
我正在尝试为 Joomla 扩展一个名为 Jquarks 的组件。该组件允许您创建分页测验,并通过来回浏览问题来回答问题或纠正答案。我认为这是由一些 Javascript 代码处理的。
我相信这是一段代码,可以使该功能发挥作用,但我不知道如何开始修改它。我想要一个包含所有页码的下拉列表,以允许用户导航到特定页面。
// adding the back next link if multi-pages
if ($nbrPage > 1)
{
if( $pNum == (int)($qNum / $nbrQuestionPage) || $qNum == $totalNbrQuestions )
{
if ($pNum == 1)
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ;
}
elseif ( $pNum == $nbrPage )
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ;
}
else
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a>
|
<a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>'
. '</span></div>' ;
}
$pNum ++ ;
}
}
$qNum++ ;
}
if ($nbrPage == 1 ) :
echo "</div>" ;
endif ;
?>
</div>
<div style="clear: both;"></div>
<div>
<p>
<?php if ($nbrPage > 1) : ?>
<input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS_CHECK_PAGES') ; ?>" id="send" name="send" />
<?php else : ?>
<input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS') ; ?>" id="send" name="send" />
<?php endif ; ?>
</p>
<p>
<a href="http://www.jquarks.org" target="_blank">Powered by JQuarks</a>
</p>
</div>
<?php
$attribs = array('type' => 'text/css');
$document->addHeadLink(JRoute::_("components/com_jquarks/assets/stylesheets/SyntaxHighlighter.css"), "stylesheet", "rel", $attribs) ;
?>
I am trying to extend a component for Joomla called Jquarks. This component allows you to create paginated quizzes, and answer the questions or correct your answers by going back and forth through the questions. I think this handled by some Javascript code.
This is the piece of code I believe makes this functionality work, but I don't know how to start to modifying it. I want to have a dropdown list containing all the page numbers, to allow the user go to a navigate to a specific page.
// adding the back next link if multi-pages
if ($nbrPage > 1)
{
if( $pNum == (int)($qNum / $nbrQuestionPage) || $qNum == $totalNbrQuestions )
{
if ($pNum == 1)
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ;
}
elseif ( $pNum == $nbrPage )
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>' .'</span></div>' ;
}
else
{
echo '<span class="jquarks_qprog"><a id="jquarksPage_' . $pNum . 'back" href="#">' . JText::_('BACK') . '</a>
|
<a id="jquarksPage_' . $pNum . 'next" href="#">' . JText::_('NEXT') . '</a>'
. '<p>' . JText::_("PAGE") . ' ' . $pNum . ' / ' . $nbrPage .'</p>'
. '</span></div>' ;
}
$pNum ++ ;
}
}
$qNum++ ;
}
if ($nbrPage == 1 ) :
echo "</div>" ;
endif ;
?>
</div>
<div style="clear: both;"></div>
<div>
<p>
<?php if ($nbrPage > 1) : ?>
<input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS_CHECK_PAGES') ; ?>" id="send" name="send" />
<?php else : ?>
<input type="submit" value="<?php echo JText::_('SUBMIT_ANSWERS') ; ?>" id="send" name="send" />
<?php endif ; ?>
</p>
<p>
<a href="http://www.jquarks.org" target="_blank">Powered by JQuarks</a>
</p>
</div>
<?php
$attribs = array('type' => 'text/css');
$document->addHeadLink(JRoute::_("components/com_jquarks/assets/stylesheets/SyntaxHighlighter.css"), "stylesheet", "rel", $attribs) ;
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是 html 下拉菜单上的 javascript 示例:
我尚未在所有浏览器中测试过此功能,但它可以在 chrome 中运行。通常我使用 jQuery,所以会是:
我将把它转换为 PHP 作为你的家庭作业;)干杯
Here's an example of javascript on an html drop down:
I haven't tested this in all browsers but it works in chrome. Usually I use jQuery so the would be:
I'll leave the converting this to PHP as your homework assignment ;) Cheers