Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript and php

Status
Not open for further replies.

hostagency

Technical User
Feb 12, 2003
9
US
Hi

I am submitting two forms from a single button. One is the standard form and the second opens in a new window via javascript from an onclick statement. That part works fine, but part of the function is a php variable - $order->info['whateverhere']and I just can't get it to work because I either have wrong syntax or I need to define a var for it or something. Here is my current form (private info is XXXXed out):

<script language=&quot;JavaScript&quot;>
function formsubmit() {
var selectedItem = document.status.status.selectedIndex;
var selectedItemValue = document.status.status.options[selectedItem].value;

if (selectedItemValue == '3') {
w=window.open('about:blank','','width=470,height=300,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
w.document.write('<html><body><form name=&quot;payflow&quot; method=&quot;POST&quot; action=&quot;w.document.write('<input type=&quot;hidden&quot; name=&quot;PARTNER&quot; value=&quot;verisign&quot;>');
w.document.write('<input type=&quot;hidden&quot; name=&quot;LOGIN&quot; value=&quot;XXXX&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;TYPE&quot; value=&quot;D&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;TRANSID&quot; value=&quot;<?php echo $order->info['verisign_ref']; ?>&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;AMOUNT&quot; value=&quot;<?php echo $order->info['total']; ?>&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;ZIP&quot; value=&quot;<?php echo $order->info['zip']; ?>&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;ADDRESS&quot; value=&quot;<?php echo $order->info['address']; ?>&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;METHOD&quot; value=&quot;CC&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;ORDERFORM&quot; value=&quot;false&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;SHOWCONFIRM&quot; value=&quot;false&quot;>');
w.document.write(' <input type=&quot;hidden&quot; name=&quot;ECHODATA&quot; value=&quot;true&quot;>');
w.document.write('</form></body></html>');
w.document.payflow.submit();
}
}
</script>

When I load the page and view source all the value=&quot;<?php.... are all empty ie. value=&quot;&quot;

The variables are already queried prior to the javascript and echoed elsewhere on the page also so I know they are working.

Any help would be most aprreciated.

Del
 
try this:
w.document.write(' <input type=&quot;hidden&quot; name=&quot;AMOUNT&quot; value=&quot;<?php echo &quot;5&quot;; ?>&quot;>');

ie put some default value and check if that comes...


Known is handfull, Unknown is worldfull
 
vbkris...thanks

Yeah - the 5 shows up....and if I do value=&quot;<?php echo &quot;$order->info['verisign_ref']&quot;; ?>&quot; then the output is ['verisign'].

Do I need to define it first in javascript like...

var verisign = $order->info['verisign_ref'];

Thanks

Del
 
no initialization is not necessary. if the output is wrong then the error is with php...

Known is handfull, Unknown is worldfull
 
I moved the javascript further down the php code and it worked. The variables were already pulled from the database so I don't quite understand, but I'm glad it works.

Thanks for your help.

Del
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top