Javascript 如何在PHP中将动态文本附加到url?
我有一个方法类型为post的html表单,现在我想用PHP将文本附加到我的网站url。文本是动态变化的 当前url:Javascript 如何在PHP中将动态文本附加到url?,javascript,php,jquery,url,url-rewriting,Javascript,Php,Jquery,Url,Url Rewriting,我有一个方法类型为post的html表单,现在我想用PHP将文本附加到我的网站url。文本是动态变化的 当前url: www.example.com/index.php www.example.com/index.php/hotels-in-bangalore 预期url: www.example.com/index.php www.example.com/index.php/hotels-in-bangalore (或) 我只想附加文本,不同的是每件事都应该保持不变。谢谢。如果要在
www.example.com/index.php
www.example.com/index.php/hotels-in-bangalore
预期url:
www.example.com/index.php
www.example.com/index.php/hotels-in-bangalore
(或)
我只想附加文本,不同的是每件事都应该保持不变。谢谢。如果要在提交后立即重定向到正确的页面,需要使用JavaScript 所以会是这样的:
<form>
<input type="text" name="tbSearch" id="tbSearch" />
<input type="submit" id="submitSearch" value="Submit" />
</form>
<script type="text/javascript">
$("#submitSearch").click(function() {
window.location.href="index.php?qry=" + encodeURIComponent($("#tbSearch").val());
});
</script>
$(“#提交搜索”)。单击(函数(){
window.location.href=“index.php?qry=“+encodeURIComponent($(“#tbSearch”).val());
});
我不确定您为什么要尝试实现这一目标,但这里有几个解决方案:
将url放入表单操作:
<form action="index.php?qry=hotels-in-bangalore" method="post">
你能发布你的HTML表单代码吗,这样我们就可以了解你想做什么了?