[英]Hide submit type input value from url
I have a form with GET method with some inputs like this: 我有一个带有GET方法的表单,其中包含一些输入:
<input type="text" name="something">
<input type="submit" name="submit" value="Click here to submit form">
I don't want the url to become 我不希望该网址成为
mypage.php?something=value&submit=Click+here+to+submit+form
I want to suppress the submit parameter in the url (should be like this: mypage.php?something=value). 我想取消url中的Submit参数(应该是这样的:mypage.php?something = value)。
I need only GET method please don't mention POST method. 我只需要GET方法,请不要提及POST方法。 Also you may mention to remove
name="submit"
but i need it also to identify this submit. 另外,您可能会提到删除
name="submit"
但我还需要它来标识此提交。
Also if there is a input from which is empty i don't want to show 另外,如果有一个输入为空,我也不想显示
<input type="text" name="input1">
<input type="text" name="input2">
<input type="submit" name="submit" value="Click here to submit form">
input1
gets value but if input2
doesn't have value the i want url like mypage.php?input1=value input1
获取值,但是如果input2
没有值,我想要像mypage.php这样的url?input1 = value
Thanks 谢谢
如果您不希望submit
参数显示在GET
请求URL中,请不要给它起一个名字,而是使用id
或class
唯一地标识它:
<input type="submit" id="submit" value="Click here to submit form">
I would remove form submit the and just turn it into a button. 我将删除表单提交并将其变成一个按钮。 Then I would use jquery to submit the form and do any logic processing.
然后,我将使用jquery提交表单并进行任何逻辑处理。
<input type="test" id="favoriteCheese" value="nacho" />
<button id="submit" value="Click here to submit form">Click here to submit form</button>
$("#submit").on('click', function () {
var data = {};
var favCheese = $("#favCheese").val();
if(favCheese.length > 0) {
data.favCheese = favCheese
}
$.ajax({
url : ".../mypage.php",
data : data,
type : 'GET',
...
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.