开发者

JavaScript to trigger PHP

开发者 https://www.devze.com 2023-01-07 06:04 出处:网络
Is it possible to have an input text box such that when a person types something and presses submit 开发者_开发技巧or enter, I can trigger PHP to submit that data to a database without leaving the pag

Is it possible to have an input text box such that when a person types something and presses submit 开发者_开发技巧or enter, I can trigger PHP to submit that data to a database without leaving the page (hence the JavaScript)?


You're going to want to look into something called AJAX. I won't add any code here because there are thousands of excellent tutorials out there that will be much more thorough than I can type here. I would recommend using the jQuery Javascript library to help out.


Yes. It's possible. Here's an example of the sort of technique you want.


You can do this by using a <form> tag with you textbox and submit button inside.

<form name="input" action="do_something.php" method="get">
<input type="text" name="Value" />
<input type="submit" value="Submit" />
</form>
0

精彩评论

暂无评论...
验证码 换一张
取 消