i can get the $amount
to show up on the page, but after I get a error telling me i need to add in an amount for it to run through the script
i just need the $amount
to be added by the $payment
, $donation
, and post the $amount
<label>Payment:</label>
<input name="payment" id="payment" class="small-field" value="<?php echo $payment;?>" />
*
<div class="clr"></div>
<label>Donation:</label>
<input type="checkbox" id="donation" name="donation" value="1.00" />
<div class="clr"></div>
<?php echo $amount;?>
I think you mean JavaScript ( or jQuery package might be easier for you ).
If I understand you correctly. Here is an example on how to do it.
<html>
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Dainis Abols" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input id="check2" type="checkbox" name="test" value="1">
<div id="check1" style="float: left;">1.00</div>
<!-- The event for checkbox with id 'check2' -->
<script>
$("#check2").click(function() {
var value = $(this).val(); /* Catching value of checkbox */
value++; /* Increasing value by one */
$(this).val(value); /* Replacing original value */
$(this).attr('checked', false); /* Removing CHECKED ( if needed ) */
$('#check1').html(value + '.00'); /* Just for visual aid */
});
</script>
<!-- End of event -->
</body>
</html>
If you wan't to change some php value with html script you'll need a form to post information to server, or use ajax to do this.
Php works just on server side, your HTML page are on client side. Both don't interact each other.
I recomend use ajax to do that in "real time". Something like that: http://api.jquery.com/jQuery.ajax/
$(function () {
$("#payment").bind('change',function () {
if($(this).checked){
$.ajax({
type: "GET",
url: "test.php",
success: function(){
alert('value as incremented by 1');
}
});
}
});
});