What I'm trying to do: I'm trying to make it so that the button reset the number to a certain value that the button is saved to. If it is selected then it will reset the the item in the array.
Problems: It does reset the one of the values in the array the problem is that when i try to reset the other values it reset the first value back to 0. When i click the first set of buttons then it resets the second set back to 0.
Example Code:
Code:<?php //shell $cscolor=0; $cscolors = array('black','white','red','blue','green','yellow','pink','purple','orange');//colors or hex only //trigger $ctcolor=0; $ctcolors = array('black','white','red','blue','green','yellow','pink','purple','orange');//colors or hex only //$allFiles = array(0,0); //resets values if(isset($_POST['one'])){ $cs = $_POST['one']; $cscolor = $cs; } if(isset($_POST['two'])){ $ct = $_POST['two']; $ctcolor = $ct; } $list = array($cscolor, $ctcolor); for($i = 0; $i <= (count($list)-1); $i++){ echo $list[$i].'<br />'; } ?> <form action="index.php" method="POST"> <?php for($item=0; $item<=(count($cscolors)-1); $item++){ if($cscolor==$item){ echo '<button name="one" type="submit" class="selected" value="'.$item.'" style="background-color: '.$cscolors[$item].'"> </button>'; }else{ echo '<button name="one" type="submit" class="colors" value="'.$item.'" onMouseOver="style.cursor = \'pointer\'" style="background-color: '.$cscolors[$item].'"> </button>'; } } ?> <br /> <?php for($item=0; $item<=(count($ctcolors)-1); $item++){ if($ctcolor==$item){ echo '<button name="two" type="submit" class="selected" value="'.$item.'" style="background-color: '.$ctcolors[$item].'"> </button>'; }else{ echo '<button name="two" type="submit" class="colors" value="'.$item.'" onMouseOver="style.cursor = \'pointer\'" style="background-color: '.$ctcolors[$item].'"> </button>'; } } ?> </form>
Extra Info: It might be because I reset the value back to 0 in the first instance of $ctcolor=0; and $cscolor=0; so it will not reset. I do not know another way around this. Any suggestions would be grateful.
Thanks



Reply With Quote
Bookmarks