2012-08-02 78 views
0

我有一个PHP页面,其上面有一个选择框的代码。PHP/HTML表格检索值

<form method="POST" action="<?php echo $a?>" name="test2" id="test2"> 
<select name="test" id="test" onchange="parentNode.submit()"> 
<?php if($_POST['submitted'] == true){ ?> 
        <?php $a = echo $_POST['test'];?> 
       <?php }else{ ?> 
       <option value="">-- select Video --</option> 
       <?php } ?> 

<?php foreach ($pages as $page): 

    // Prepare data for each page being listed... 
    $title = $th->entities($page->getCollectionName()); 
    $url = $nh->getLinkToCollection($page); 
    $target = ($page->getCollectionPointerExternalLink() != '' && $page->openCollectionPointerExternalLinkInNewWindow()) ? '_blank' : $page->getAttribute('nav_target'); 
    $target = empty($target) ? '_self' : $target; 
    $description = $page->getCollectionDescription(); 
    $description = $controller->truncateSummaries ? $th->shorten($description, $controller->truncateChars) : $description; 
    $description = $th->entities($description); 


    <h3 class="ccm-page-list-title"> 
    <option value="<?php echo $url ?>"> 
     <?php echo $title ?> 
    </option> 
    </h3> 


<?php endforeach; ?> 
</select> 
<input type="submit" value="go" name="Watch Video" /> 
<input type="hidden" name="submitted" id="submitted" value="true" /> 
</form> 

上面的表格具有页面名称作为选项,值作为URL链接。现在,我要的是所选/选项重定向提交URL值的用户(请参阅下面的选项例子)

<option value="/index.php/video-gallery/latin-america/mtw-2011-destination-report-mexico-city/">MtW 2011 - Destination Report: Mexico City</option> 

所以,我要的是重定向到选定的值URL我靠近页面它只是设置提交给变量选定的值线不工作<?php $a = echo $_POST['test'];?>

这甚至可能没有JavaScript或重定向到另一个redirect.php页面,查找重定向的值,然后加载该页面?

回答

0

没有,这是不可能没有JavaScript

0

你可以做这样的事情 -

// do your redirect here 
    header('Location: '. $_POST["test"]); 
    exit(); 

但JQuery的会去做

的最佳方式