我恳请您输入如何通过 URL 将变量发送到其他 PHP 站点:
<form action="deny.php" method="get">
<div align="left"></div>
<p><span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span></p>
<p><span class="style13" style="height: 23px;">
<input type="hidden" name="id" value=<? echo $id; ?> />
</span> </p>
<p>
<? echo '<td><a href="deny.php?submit='.$id.'&deny='.$_GET['deny'].'">Send Feedback</a></td>'; ?>
</p>
</form>
$id
是正确的,但是$deny
是空的
我什至尝试使用 $deny(而不是 $_GET['deny'])和 $_POST[deny]
- 但 $deny
始终为空。 (可以在链接中控制)
感谢您的建议!
BR,
斯特凡
最佳答案
将您的代码替换为以下代码:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<form action="deny.php" method="get">
<div align="left"></div>
<p><span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span></p>
<p><span class="style13" style="height: 23px;">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
</span> </p>
<p>
<a href="#" id="feedbackLink">Send Feedback</a>
</p>
</form>
<script type="text/javascript">
$( document ).ready(function() {
$('select[name="deny"]').change(function(){
var link = 'deny.php?submit=<?php echo $id; ?>&deny=';
$('a#feedbackLink').attr('href', link + $(this).val());
});
$('select[name="deny"]').trigger('change');
});
</script>
不提交表单就不能使用$_GET、$_POST等变量。
希望这能解决您的问题。
关于PHP:将变量从下拉列表发送到 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27562646/