i think that the best solution is to use XMLHttpRequest
mihai
ps. i don't think is a good idea to save the shopping cart in a cookie
on client side (i can alter, as a client, the prices from shopping cart)
Han wrote:
Hi,
I can think of 2 solutions:
1 is an old one I used ages ago, and it was to use javascript to put
their choices (onclick, field.value=£3 type of thing) and when they
click the OK button it gets sent to php script that sends it to mysql, etc.
2 is pretty much the same but using cookies with javascript.
Example : --
<script language="JavaScript">
<!-- Hide from old browsers
//Hide from Java Script
function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ");
for (i=0; i<thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1];
}
}
return 0;
}
//-->
</script>
<script language="JavaScript">
<!-- Hide from old browsers
//Hide from Java Script
function SetCookie(value1,value2,value3){
var greetName = cookieVal("mysession");
if(greetName == 0){
document.cookie = "mysession" + "=" + value1 + ":" + value2 + ":" +
value3 +":1%" + "; path=/; expires=19 January 2038 03:14:07";
var addme= value +":1%";
}
else{
document.cookie = "mysession" + "=" + greetName + value1 + ":" + value2
+ ":" + value3 + ":1%" + "; path=/; expires=19 January 2038 03:14:07";
var addme = value +":1%";
}
theURL="http://www.domain.com/cgi-bin/showbasket.cgi?cookievalue="+addme;
winName="order3";
features="scrollbars=yes,width=400,height=600";
child = window.open(theURL,winName,features);
child.focus();
}
//-->
</script>
<a href="#"><img src="images/image1.jpg" alt="image1" width="80"
hspace="5" vspace="3" border="0"
onClick="javascript:SetCookie('555435,£3,image1');">"></a>Hope this helps.
Han.
----- Original Message ----- From: "Chris Payne" <cjp@xxxxxxxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Sent: Thursday, June 09, 2005 5:33 AM
Subject: Page refresh question
Hi there everyone,
I'm using PHP and MySQL in a shopping cart system but the client wants
it so
that when you add an item to the cart the page doesn't refresh and we all
know with PHP the page MUST refresh in order to execute the MySQL
query. Is
it possible, maybe with javascript? That I can talk to MySQL without
having
to have the page itself refresh when they add the items to the cart?
This
is really a pain as the system was basically finished and now I'm told
they
don't want the page to refresh and they see other sites that don't
refresh -
sigh. If it can be done with Javascript, do you have a sample of how
I can
use PHP, Javascript and MySQL together to achieve this please?
Any help would not only be appreciated, but would save my life.
Thank you.
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php