I'm trying to set the values of a hidden field, dependent on which one of two buttons is clicked.
If attendYes is clicked, it should set attend to 1, whereas if attendNo is clicked, it should set attend to 0. It's currently saving the value as blank which would suggest it is not being set.
(Ignore the excess CSS... Adobe Muse is a nuisance when exporting)
Form with buttons
<form id="form1" name="form1" method="post" action="playerparent-profile.php?pid=<?=$pid?>">
<div class="clearfix colelem" id="pu11327-5"><!-- group -->
<div class="clearfix grpelem" id="u11327-5"><!-- content -->
<p> <span id="u11327-2"><button type="submit" id="attendYes" class="global-button">Yes</button></span></p>
</div>
<div class="clearfix grpelem" id="u11329-5"><!-- content -->
<p> <span id="u11329-2"><button type="submit" id="attendNo" class="global-button">No</button></span></p>
</div>
</div>
</div>
</div> <input name="attend" id="attend" value="">
</form>
Javascript
<script type="text/javascript">
if ($('#attendYes')) {
$('#attendYes').click(function(e) {
document.getElementById('attendYes').value = "1";
$('#form1').submit();
return false;
});
}
</script>
<script type="text/javascript">
if ($('#attendNo')) {
$('#attendNo').click(function(e) {
document.getElementById('attendNo').value = "0";
$('#form1').submit();
return false;
});
}
</script>
I have no doubt the actual javascript is the issue, but I'm not sure WHAT, as it looks as though it makes sense to me. Any help would be greatly appreciated.
Cheers.