<script type="text/javascript">
function add( name ) {
document.getElementById( name ).value ++;
}
function substract( name ) {
if ( document.getElementById( name ).value > 0 )
document.getElementById( name ).value --;
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<form>
<input type="text" value="1" id="quantity" size="2" maxlength="4" onkeypress="return isNumberKey(event);">
<a onClick="add(‘quantity’);" >plus</a>
<a onClick="substract(‘quantity’);"> minus</a>
</form>
function add( name ) {
if (document.getElementById( name ).value < <?php echo intval($stock); ?>) {
document.getElementById( name ).value ++;
}
}
<form action="basket.php" method="get">
<input type="hidden" name="action" value="add" />
<input type="hidden" name="r" value="<?php echo htmlspecialchars($ref); ?>" />
<input type="hidden" name="l" value="<?php echo htmlspecialchars($wording); ?>" />
<input type="hidden" name="p" value="<?php echo htmlspecialchars($price); ?>" />
<input type="text" value="1" id="quantity" name="yourquantityattribute" size="2" maxlength="4" onkeypress="return isNumberKey(event);">
<a onClick="add(‘quantity’);" >plus</a>
<a onClick="substract(‘quantity’);"> minus</a>
<button type="submit"><img src="images/product-details/caddieshop.png"></button>
</form>