2012-08-02 84 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的會去做

的最佳方式