admin管理员组文章数量:1392054
I have a form with GET method with some inputs like this:
<input type="text" name="something">
<input type="submit" name="submit" value="Click here to submit form">
I don't want the url to bee
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).
I need only GET method please don't mention POST method.
Also you may mention to remove name="submit"
but i need it also to identify this 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
Thanks
I have a form with GET method with some inputs like this:
<input type="text" name="something">
<input type="submit" name="submit" value="Click here to submit form">
I don't want the url to bee
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).
I need only GET method please don't mention POST method.
Also you may mention to remove name="submit"
but i need it also to identify this 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
Thanks
Share Improve this question edited Mar 27, 2014 at 20:52 kero 10.7k5 gold badges43 silver badges52 bronze badges asked Mar 27, 2014 at 20:50 Sharif AhmedSharif Ahmed 931 gold badge2 silver badges10 bronze badges 3-
3
What is the technical limitation that is preventing you from utilizing
POST
? – esqew Commented Mar 27, 2014 at 20:52 - You can do it using javascript. Have the submit button outside the form, and when submit is clicked, using javascript submit the form. – dewd Commented Mar 27, 2014 at 20:54
- Is possible hidden value if field is empty with javascript, but if you need to get value from submit button, is not possible to hidden this value. – gabrieloliveira Commented Mar 27, 2014 at 20:59
2 Answers
Reset to default 6If you don't want the submit
parameter to show up in your GET
request URL, don't give it a name, and instead use id
or class
to identify it uniquely:
<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.
<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',
...
})
})
本文标签: javascriptHide submit type input value from urlStack Overflow
版权声明:本文标题:javascript - Hide submit type input value from url - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744782298a2624787.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论