-3

I have a form that can add information in database using php/mysql. I can make that form to show in pop up window and can insert data in database. Suppose I have city form which have city_id, city_name, city_abbreviation. I have create a html form that can insert data in city table using php/mysql. Now I want to make pop up form and insert data in database.

Manolo
  • 24,020
  • 20
  • 85
  • 130
user3215780
  • 45
  • 1
  • 4
  • What are you asking? What problem are you having? What have you done? What works? Doesn't work? Can you try to explain this question better? – gen_Eric Jan 20 '14 at 16:35
  • SO is not a `code depot`. The Internet is literally plastered with code and tutorials. **Don't be Lazy** – Funk Forty Niner Jan 20 '14 at 16:36
  • i have made a simple form that can insert city_id, name,abbreviation in database now i want that there is button by clicking that button a pop up form displayed that can perform same function. i.e insert data into database. – user3215780 Jan 20 '14 at 16:58

1 Answers1

0

The easiest way to do this is to use jQueryUI's dialog() widget. It's unbelievably simple:

 $('#someDivID').dialog();

The above command takes whatever it inside the div containing the attribute id="someDivID" and displays it in a pop-up. The displayed DIV works exactly the same as it would without being in a pop-up.

Note that you must have both the jQuery library and the jQueryUI library referenced in your document, as per > this other question < with a more complete explanation of the jQueryUI dialog widget.

Since you already know how to create a form and submit it to a PHP file for entry into a MySQL database, I won't repeat that here -- but if you need help with that, leave a comment.

Next, you might wish to know how to input the form data into the database without leaving the page you are on. That is, the popup will close and you want the data to be placed into the database "behind the scenes", without changing to a different page.

That is done via AJAX -- also unbelievably simple. Please see these additional posts for information:

A simple example

More complicated example

Populate dropdown 2 based on selection in dropdown 1

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111