Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Jackie Jen
2,723 Pointscan javascript input data send to server php when click submit button?
Below is the case:
I have create a small button for user to click. when user clicked the small button, it will show the "div". Inside the "div" have a html submit button and an input textbox . When user input the text and click submit button. I would like to send the data to my mysql.
The problem i have met is how to send the data to my mysql when submit button is clicked? I have no idea, since all the time i'm using php to send data to update mysql.
Is there any similiar example for me to reference?
1 Answer

Hugo Paz
15,622 PointsIf i understand you correctly, you are using javascript to display the div, correct? Why not simply do something like this
<div id="hidden-div">
<form action="formProcessing.php" method="post">
<input type="text" name="data">
<input type="submit">
</form>
</div>
You use php to deal with the form and javascript to show/hide the form.
Logan R
22,989 PointsLogan R
22,989 PointsI would use JQuery. There are some nice .show() hide() that makes it super easy to do.
Jackie Jen
2,723 PointsJackie Jen
2,723 PointsThanks Hugo & Logan.
Hugo,Thanks for the idea. It really help me alot.