Let me start by saying that I have limited experience with php, and considerably less experience with javascript. So please keep this in mind when giving me advice (in other words keep it simple if possible).
Now to the problem. I have a page which is intended to allow the user to configure a computer and, then pass on the price and description to the cart. The price is updated automatically (and w/out refreshing the page) by what I understand is a very primitive javascript -> innerHTML code. This code only works in ie and opera (but that is a problem for another post.)
The javascript is as follows:
<script language="JavaScript">
<!--
function updatePrice(){
if(document.all){
i=1
total=1795
while(i<=18){
selectit=eval("document.config.select"+i)
total+=parseFloat(selectit.value)
i++
}
totalvalue.innerHTML=total
}
}
totalvalue is then displayed wherever it is needed on the page.
Ok so now I need to pass this price (totalvalue) to my cart
I have it set up so this is done by php, calling the showcart page with price as a paramater would do the trick.
Something like this is what I have been tinkering with.
display_button("showcart.php?price=totalvalue", 'addtocart', 'Add to Cart');
Obviously this doesnt work.
What appears in the url is this:
http://localhost/issite/index.php?action=showcart.php?price=totalvalueaddtocart
What i need is for totalvalueaddtocart to read as 1820addtocart (in the case that 1820 is the price, or the value stored in totalvalue).
My guess is it doesnt work because you cant reference innerHTML inside php, and since you also can't reference a javascript variable inside php, I'm out of ideas.
Is there a workaround of this. I need a way to store the price in a variable that is accessable to my display_button function.
It's been suggested to me that I should use a hidden frame, but I still do not see how that would be effective, can anyone offer an example?
Any help would be more than appreciated.
Richard Rollier