views:

112

answers:

4

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)?

+1  A: 

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

Kalium
+7  A: 

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.

Matthew J Morrison
thanks this answered my question.
Matthew Carter
Thanks again i just saw a tutorial on W3C and its kinda easy
Matthew Carter
A: 

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>
APShredder
This isn't what he's asking for - he said, "without leaving the page".
Matthew J Morrison
...aha! unexpected answer... lol
Reigel
Oops. Guess I should read the question more carefully next time.
APShredder
A: 

Yes it is possible.

If you are just starting out I would suggest w3schools.com as an great place to learn all about web-technology.

AeroJoe
+1 because this didn't deserve a -1.
Matthew J Morrison