Hi,
I have written an AJAX/PHP script which basically passes a hex code through to the process.php file and brings back a coloured DIV of that hex code.
I now want to convert that select box into a series of submit buttons which are styled to be the colourof the hex code.
When clicked, the DIV will be returned the colour of that submit button.
I have it firing the AJAX, only issue is that no matter what colour button I click, it comes back white.
Any ideas?
Code:
<script color="text/javascript">
$(document).ready(function() {
$('#shirt').delegate('input,select,checkbox,submit,button', 'keyup change change click click', function(){
var colorvar = $("#color").val();
var id = $("#productId").val();
var selcolor = $("#colorbutton").val();
$.post("process.php", { color: colorvar, productId: id, colorbutton: selcolor }, function(data) {
$("#status p").html(data);
$("#shirt").bind("keypress", function(e) {
if (e.keyCode == 13) return false;
});
});
return false;
});
});
</script>
<div align="center">
<form id="shirt" name="shirt" method="POST">
<?php
//this bit makes the buttons
while($row = mysql_fetch_array($fetch_color_options)) {
$color = $row['Color'];
$hex = $row['HexCode'];
echo '
<input type="hidden" name="productId" id="productId" value="'.$prodId.'">
<input type="hidden" name="color" id="color" value="'.$color.'">
<input name="colorbutton" id="colorbutton" value="'.$color.'" type="button" style="border-width:6px; background:#'.$hex.';">
';
}
?>
</form>
<div id="status">
<p></p>
</div>
<br><br>
</div>
You can view/firebug the script at:
http://geewizzcubecart.co.uk/modules...l.php?prodId=2
Thanks
Dan