Page 1 of 1

php variables in javascript

Posted: Thu Mar 24, 2005 12:17 am
by shiznatix
i am trying to open a new window on hitting submit but with passing variables with the form that has the submit button. i believe this would consist of javascipt with some php maybe but how would i submit the varialbes in the form with the outside javascript. here is the code i have now.

Code: Select all

<SCRIPT LANGUAGE=&quote;javascript&quote;>
<!--
window.open ('view_cart.php?action.php?action=add_item', 'newwindow', config='height=100,
width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no')
-->
</SCRIPT>

<form action=&quote;view_cart.php?action=add_item&quote; method=&quote;post&quote;>
<img src=&quote;img/Stencils/mazdaspeedstencils.jpg&quote; width=&quote;491&quote; height=&quote;45&quote;><br>
Price: $2.50<br>
<input type=&quote;hidden&quote; name=&quote;itemName&quote; value=&quote;MazdaSpeed Caliper Decal/Stencil&quote;>
<input type=&quote;hidden&quote; name=&quote;itemPrice&quote; value=&quote;2.50&quote;>
<input type=&quote;submit&quote; name=&quote;submit&quote; value=&quote;Add To Cart&quote; onClick=&quote;window.open();&quote;>
</form>
but this dosnt work.

Posted: Thu Mar 24, 2005 12:30 am
by feyd
you can...
  1. iterate through the form on submission request creating a url with get data, then call the popup.
  2. generate the popup on submission, then pass the data to a waiting script on that page.
  3. choose to not use a popup ;)

Posted: Thu Mar 24, 2005 12:36 am
by shiznatix
a. (no idea how to do that)
b. (how would i make the popup come up before i passed the data)
c. (not a option :D )

im confused as to how to do these things

Posted: Thu Mar 24, 2005 12:53 am
by feyd
well..
  1. the code you posted thus far will immediately try to create a popup...
  2. open() returns a window object. You can send data through it..

Posted: Thu Mar 24, 2005 10:17 am
by shiznatix
ahhh thanks feyd i got it. if anyone has the same problem open a blank window with
onclick="window.open('', 'windowName');" then have the form target as windowName