0

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

12
  • 2
    Read up on jQuery, spelling, and grammar. Commented Jul 12, 2010 at 4:26
  • 3
    +1, not sure why you were getting -1 votes - this is an honest question from somebody who just needs to entry level ajax help. Commented Jul 12, 2010 at 4:29
  • 2
    @Matthew: you probably got -1 (-2 now) because of the lazy spelling and grammar. English as a second language is one thing, but that doesn't seem to apply here. Commented Jul 12, 2010 at 4:30
  • 6
    @Matthew: I translate your comment as "I don't have enough respect for you to pay attention to how I communicate." Commented Jul 12, 2010 at 4:35
  • 2
    @Matthew Then why are you asking us for help? If you don't respect us enough to pay attention to how you communicate, then how is it you respect us enough to want our opinion(s)? Commented Jul 12, 2010 at 4:41

3 Answers 3

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks again i just saw a tutorial on W3C and its kinda easy
1

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

Comments

-2

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>

2 Comments

This isn't what he's asking for - he said, "without leaving the page".
Oops. Guess I should read the question more carefully next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.