我把symfony表单变成了一个模板:
Template.php
<form class="well" action="<?php echo url_for("@submitParam?param=".$con) ?>" method="post">
<input type="text" name="param">
<button type="submit" class="thisBtn">Button</button>
</form>当按下提交按钮时,我如何将一个值从name="param"输入$con传递给url,或者使用jquery、javascript或任何其他方式(symfony或phpE 212)传递给变量$con?
更新:您也可以使用AJAX:
$(".btn").live('click', function(){
$.post("<?php echo url_for('@submitParam'); ?>", $('.box').serialize(), function(response) {
switch(response.status) {
case 'success':
console.log("Success");
break;
case 'failure':
console.log("Failure");
break;
}
}, 'json');
return false;
});行动:
$request->getParameter('param');发布于 2012-08-02 07:51:53
若要在url中发送param值,请使用submit按钮
<input type="submit" class="thisBtn" value="button"/>和改变方法来获得
method="get"
发布于 2012-08-02 07:47:03
你为什么要这么做?您已经有了param的值,因为它是表单中的一个输入元素。
https://stackoverflow.com/questions/11773093
复制相似问题