0

在第 1 页上,我尝试通过 url 将一些参数传递给 page2。我想启动 page2 并选择选项,就像我在 page2 上选择它们一样。

如何从第 1 页传递 #divOptionToTake、#divSelectChannel_btnSubmit、#selected_channel_new、#selChannels、#frmSelectChannel 并执行它?谢谢。

第1页

...../page2.php?selected_channel=facebook&option_to_take

第2页

<html>

  <script type="text/javascript">        
    $(document).ready(function() {

        <?php if($option_to_take == ""){ ?>
        $.blockUI({ message: $('#divOptionToTake'), css: { width: '420px' } }); 
        <?php } ?>

        // SELECT CHANNEL
        $('#divSelectChannel_btnSubmit').click(function() {                
            $.unblockUI();
            $('#selected_channel_new').val($('#selChannels').val())
            $('#frmSelectChannel').submit();
            //return true;               
        });            

    });  
  </script>

</html>

表格的代码在这里。

<form name="frmSelectChannel" id="frmSelectChannel" action="" method="POST">
<input type="hidden" name="task" value="select_channel" />
<input type="hidden" name="option_to_take" value="new campaign" />
<input type="hidden" name="selected_channel" id="selected_channel_new" value="facebook" />
<div id='divSelectChannel'>
        <select id='selChannels' class='span3'>
                        <option value="facebook" <?php echo (($selected_channel == "facebook") ? "selected='selected'" : ""); ?>>facebook</option>
                        <option value="twitter" <?php echo (($selected_channel == "twitter") ? "selected='selected'" : ""); ?>>twitter</option>                                                         
        </select>
            <input class='btn btn-primary' type='submit' id='divSelectChannel_btnSubmit' value='Submit' />
        &nbsp;&nbsp;
              <input class='btn' type='button' id='divSelectChannel_btnBack' value='Back' />
        </div>
   </form>
4

1 回答 1

0

您需要使用$_GET全局变量检索 url 的值;如何执行此操作的示例:

<?php
if (isset($_GET['option_to_take']) {
    $option_to_take = $_GET['option_to_take'];
}
else {
    $option_to_take = '';
}
?>

如果我误解了您想要的内容,请告诉我,以便我修改此答案。

于 2012-05-17T20:21:42.917 回答