【问题标题】:Dropdown box changes header location PHP下拉框更改标题位置 PHP
【发布时间】:2015-03-14 15:21:15
【问题描述】:

我正在编写一个 PHP 脚本,该脚本将在进行下拉选择时更改用户当前所在页面的标题,页面将保持不变,但信息会改变。我可以通过手动更改 URL 栏中的位置来做到这一点,但到目前为止还无法自动更改标题。

<select name = "rowno" onchange=header("Location: /Work/Log/new.php?rowno=$rowno")>

我完全不确定如何做到这一点,所以任何帮助将不胜感激,我已经将 $rowno 设置为变量。

编辑

$header = $entry[ID];
$iCountHeader = count($header);
echo '<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">';
for ($i = 0; $i < $iCountHeader; ++$i )
{
echo '<option value ="/Work/Log/New.php?rowno=' . $header[$i] . '">' . $header [$i] . '<option>';
}

例如,这使我可以转到“http://localhost:8800/Work/Log/1”,但我仍然无法转到“http://localhost:8800/Work/Log/new.php?rowno=1”

【问题讨论】:

    标签: php sqlite url drop-down-menu location


    【解决方案1】:
    $aHeaders = array( '1', '2', '3' );
    $iCountHeaders = count( $aHeaders );
    echo '<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">';
    for( $i = 0; $i < $iCountHeaders; ++$i )
    {
        echo '<option value="/Work/Log/new.php?rowno=' . $aHeaders[ $i ] . '">' . $aHeaders[ $i ] . '</option>';
    }
    echo '</select>';
    

    【讨论】:

    • 这几乎可以工作了,当我从列表中选择选项时,它会将我重定向到:localhost:8800/Work/Log/1,而我需要它转到localhost:8800/Work/Log/new.php?rowno=1。对不起,真的没有帮助!
    • 更改 $aHeaders 数组中的链接以匹配您想要的任何内容,或根据需要编辑 /Work/Log/new.php 的选项值 pre-pend。
    • 我真的很抱歉,但我现在非常困惑!我已经更新了我的原始帖子以显示我所做的更改,但我仍然不确定如何让它工作。就像我说的我可以去 localhost:8800/Work/Log/1 但我不明白如何在这个窗口前加上'new.php?rowno=1'。
    • 你的 $header = $entry[ID];变量需要是选项循环遍历的数组。使其成为静态然后调整以转换为动态。 $header = array($entry[ID]);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多