-
Posts
425 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by JamesB
-
-
In this thread http://w3schools.invisionzone.com/index.php?showtopic=51196 in the link he gave: http://jsfiddle.net/96eLrn6e/
He defines 2 local variables in a lambda, but then uses one of those variables outside the lambda, why does that work?
I was thinking that the local variables in the lambda would be destroyed when the lambda finishes executing.
-
Use onkeyup instead.
The element's value hasn't been updated until both functions have finished executing.
- 1
-
But he's sending it as a parameter
-
yeh
I'm not sure which event will take priority for disabling the input on this one: but both functions should be called.
<input id="lol" type="text" name="form_number" size="20" onkeypress='return isNumberKey(event)' onkeydown='return isNumberKey(event)'>
<input id="lol" type="text" name="form_number" size="20" onkeypress='return (isNumberKey(event) && function2(event))'>
- 1
-
What's your code so far?
-
Okay, but can you please post your latest code?
-
-
That line looks fine.
What is your latest code?
And did you delete your cookies?
-
What's the latest code you have?
-
Remove this line: $sql.=$id.",";
Then add: echo $sql; after your foreach loop.
You will need to reset your cookies and run the page again which stores data into the session.
-
Okay, check my previous post though I posted another update.
And dont forget to update this one from 'cart' to 'paniers'
<td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity'];?>€</td>
-
Also in paniers.php, change
$this->name = $nom;
to
$this->nom = $nom;
and change
foreach($_SESSION['paniers'] as $id =>$value) {$sql.=$id.",";}
to
foreach($_SESSION['paniers'] as $name=>$value) {$sql.="'".$name."',";}
-
Rename your other 2 occurrences of $_SESSION['cart'] to $_SESSION['paniers']
-
change
if(isset($_SESSION['cart'])){
to
if(isset($_SESSION['paniers'])){
you forgot to rename one
-
yeh basically.
$_SESSION is an array.
$_SESSION['cart'] is an element in that array.
So somewhere in your code a value should be assigned to $_SESSION['code'].
Can you post the code in panier.php?
-
I don't see 'cart' in that output. So $_SESSION['cart'] is not set.
-
That would suggest to me that this line is evaluating to false:
if(isset($_SESSION['cart'])){
try debugging your session by adding:
print_r($_SESSION);if(isset($_SESSION['cart'])){
-
When u run the file, which number is being displayed on the page? a zero?
-
Check how many rows are returned in your query
$query=mysql_query($sql);echo mysql_num_rows($query).'<br>';
-
Well you are overwriting the $produit variable from the database.
Try removing the foreach loop.
Change
<?php foreach($listproduit as $produit) { ?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td></tr><?php } ?>
to
<tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td></tr>
-
Okay forget the semilcolon.
Try changing:
</tr><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>
to:
</tr><?php } ?><?php } ?><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>
-
Well it should work, are you sure your while loop code works? Try adding print_r($battlepokemon); after your while loop to verify the array data.
-
You are missing a closing bracket } for:
if(isset($_SESSION['cart'])){
and
<?php } else {?>
Also you haven't put a semicolon at the end of these 4 PHP lines:
<td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td>
-
foreach($battlepokemon as $key => $value){ $battlepokemon[$key]['battle_health'] *= 2;}
Variable scope in lambda
in JavaScript
Posted
Ah thanks! had a feeling it was that.