Hi,

I had a similar problem to this shopping cart some time ago, and I handled
it that way:

Within a form the user (it's made for salesmen) can add lines of articles,
text etc to build up an offer.

The price for the added articles can be choosen from different pricelists
given in a database.

Within this form offer a double-click on the field articlenumber calls the
JavaScript function
NeuPreisl() with a parameter $pos to reflect the selected line.
This Javascript function opens a Popup window, where the user then can
select the price for this article
which in a further step is passed back to the form offer where all action
started.

...
echo "<input type=text name='artnr' size='15' maxlength=20 value='' readonly
style='background-color:$bgcolor3;' onDblClick=\"NeuPreisl('$pos')\"
title='Doppelklicken f&uuml;r Preisliste'>";
...

The JavaScript function Neupreisl() looks like this, where at the beginning
I build up
the URI in uristr, the selected articlenumber which is already in the form
(but not returned to and known by PHP and the Server at this moment!!)
is stored in an array artikelnummer[] with the passed argument $pos as
index.
A new window in the browser is opened and the arguments articlenumber and
some other
are returned to the serverside PHP-Script script.php
(which afterwards makes a DB-query and populates the new window with some
data).
The variable $mode is used to control the action within script.php.

function NeuPreisl(posnr) { // Pricelist
 var artikelnummer= this.document.frm['artikelnummer'+posnr];  // reading
the artikelnummer of this line
 var artnr= artikelnummer.value;                               // getting
the value
 var uristr=
"../script.php?PHPSESSID=$PHPSESSID&mode=searchprl&artikelnummer="+artnr;
 SuchePreisl =
 window.open(uristr, "Suchfenster",
"dependent=yes,width=500,height=200,scrollbars");
 SuchePreisl.focus();
}

Hope this helps a little bit
Franz

-----Ursprüngliche Nachricht-----
Von: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 10. September 2002 17:20
An: [EMAIL PROTECTED]
Betreff: [PHP-DB] PHP in a javascript function with DB calls.


Hi All,

I HOPE this is the right place for this.. if not I am sorry!!!



I'm hoping someone can put me on a clear path of how to do what I am
asking here.

I Have a shopping cart... and in this shopping cart I want to feature
some items in a pop_up window when the user is ready to check out - if
they are not already selected.

For example.. Someone buy a Hockey Stick but don't buy hockey tape..

when when they go to check out.. I want a pop_up to be launched asking
the user if they want to add Hockey tape to their order for onlu $$$.

For this to happen I need to have an onLoad on the checkout page that
calls a javascript function that has PHP code to find out IF a
paritcular product is selected to see if the other has been selected
too, if it's NOT selected then launch the pop_up.

Does ANYONE have any idea's as to how this can be accomplished??

Anyhelp is appreciated!!!!

thanks all.

Aaron




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to