Forum Moderators: open
function set_cookie(){
var total = document.order.GrandTotal.value;
var items = document.order.Cart.value;
var stuff_for_cookie = total + "///" + items;
document.cookie = escape(stuff_for_cookie);
}
next page (with contact form)
<script type="text/javascript">
var cookie_stuff = unescape(document.cookie);
var crumbs = cookie_stuff.split("///");
var total = crumbs[0];
var items = crumbs[1];
</script>
<?php $total = $_POST['total']; ?>
<script language="JavaScript">document.write(total)</script>
<?php //$item = $_POST['item']; ?>
<script language="JavaScript">document.write(items)</script>
<?php
What im doing it passing the total and multi items from a menu page into the contact form.
With the about code, i get the total, but it wont pass into a php veriable:
$total = $_POST['total'];
//shopping results
$message = " $todayis [EST] \n
Attention: $attn \n \n
Message: $message \n \n
Order Items: $items \n
Total Price: $total \n
";
the $total = $_POST['total']; does nothing, ive also tried $_GET... nothing displaying, the variable is still empty.
The Cart ( var items = document.order.Cart.value; )
how can i get the list displaying from that? is it a while loop, an array?
Im totally new javascript :s
Thanks to anyone who can help.. :D
maybe im doing something wrong~
----
but it wont pass into a php veriable:
$total = $_POST['total'];
//shopping results
$message = " $todayis [EST] \n
Attention: $attn \n \n
Message: $message \n \n
Order Items: $items \n
Total Price: $total \n
";
this code is after i submit the contact form. I was trying to use the cookie to pass the values into that. as you can see with the 'total' var.
the bottom code is on the same page, (after contact has been submitted.. using isset..)
next page (after contact form)
<script type="text/javascript">
var cookie_stuff = unescape(document.cookie);
var crumbs = cookie_stuff.split("///");
var total = crumbs[0];
var items = crumbs[1];
</script>
<?php $total = $_POST['total']; ?>
<script language="JavaScript">document.write(total)</script>
<?php //$item = $_POST['item']; ?>
<script language="JavaScript">document.write(items)</script>
<?php
So what im trying to do, is with these codes, passing the values from the user interaction menu to select items, then it passes it into a cookie, they submit the menu page, then the contact form opens, after submitting that, it sends email and opens (for testing) a page. Its this page where i have this code to try open the cookie, and send the values into $... vars to connect to the message (email) so they can see what they have ordered.
Hope this clears it up. There is not <form> on this page.
it sends email and opens (for testing) a page. Its this page where i have this code to try open the cookie, and send the values into $... vars.
You have a page say test.php in which you need $total, that needs to come from the url get/post request, or from the php code reading the cookie directly, you can not use js to get it because the js is not executed on the server.
So look at where test.php is opened, can it be opened as "test.php?total="+total ?
If that is not possible I guess php can read the cookie, I have no experience of doing that.