pop up window

hello, i just wanted to ask for help about my code. what i wanted to happen is that when i click the button "add to cart" a pop up window will appear. here's my code:

<form action="menu.php">      
                                                            
                              <?php
                              include ("db.php");
                              
                              $data = mysql_query("SELECT price,prod_desc FROM product WHERE prod_no='1'")  or die(mysql_error());
                              while($row= mysql_fetch_array( $data )){
                                    echo"<tr><td>".$row['prod_desc'] . "</td>";
                                    echo"<td>"."<input type='number' name='qty' min='0' />"."</td>";
                                    echo"<td>".$row['price'] . "</td>"; }
                              ?>
                              <div id="cart">
                              <td><input type="submit" value="Add to cart" class="btnAddAction"/></td></tr>
                              </div>
</form>
potatozeroAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
to pop up a new window, you can try use javascript: windows.open, like:
<input type="submit" value="Add to cart" class="btnAddAction" onclick="window.open('newpage.php')"/>

Open in new window

or you can use jQuery to have a "pop up", like:

Best 10 jQuery Popup Window Tutorials
http://www.sitepoint.com/10-jquery-popup-window-image-slider-plugins/

try see which approach is best suit your needs

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aboo_sCommented:
Your code will redirecrt to another page, menu.php
No popup is executed, to do this you will have to use javascript or jquery.
Steven KribbeSoftware EngineerCommented:
The button is now of type submit which means it will submit the form causing a page refresh. From the looks of your form fields I am not sure what you are trying to accomplish after the submit. There is not enough info to bind your qty values to the products.

Anyway, of course you can use the onclick event to open a popup window like this:

<input type="submit" value="Add to cart" class="btnAddAction" onclick="window.open('<URL>' );"/>

where <URL> is he page you want to open in the popup.

If you are using jQuery there are more elegant way to do it.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

aboo_sCommented:
Now the trick is to pass your values to this new popup.
I think you can use get method to acheive this:
something like this:
<input type='submit' onclick="window.open('handle_cart.php?<?php echo 'parameters'; ?>')"
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
alternatively set the form's target so that instead of page redirect itself, it will post with a new pop up... like:

<form action="menu.php" target="_blank">  

HTML <form> target Attribute
http://www.w3schools.com/tags/att_form_target.asp

but again you need to tell us with more details what you intend to achieve.
aboo_sCommented:
this will render javascript like this:
<input type='submit' onclick="window.open('handle_cart.php?item_name='first_item&item_desc=whatever&item_price=800')"

Now create your hadle_cart.php page to deal with this.
Ray PaseurCommented:
Popup windows are not a PHP question - browser behaviors are controlled by JavaScript.  But the use of the PHP MySQL extension is a dangerous and outdated practice that must be corrected as soon as possible.  This article shows what is changing in PHP and teaches how to fix your scripts.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.