Jump to content

Strange behaviour from checkboxes


Ninjakreborn

Recommended Posts

The no_enddate.  When it's checked it should hide the end date field and disable it. When it's not checked it shouldn't.  This was working fine.  Now all of a sudden I added "registered_headline". If that checkbox is checked then the stuff for no_enddate doesn't work. If it isn't checked, then it continues to work fine.

 

Any advice?

 

        <label for="registered_headline">Only show to registered users:</label><input name="registered_headline" <?php if ($registered_headline == 1) { echo 'checked="checked"'; } ?> type="checkbox" class="checkbx" />
        </fieldset>
        <fieldset class="choosedates"><legend>Run Dates</legend>
        <label for="start_date"><span style="color:red;">*</span>Start Date:</label><br/><input name="start_date" id="start_date" class="date_pick" type="text" value="<?php echo $start_date; ?>" /><br />
		<br/><label for="no_enddate"><strong>Run Promotion continuously with no end date?</strong></label>
        <script type="text/javascript">
	$(document).ready(function() {
		if ($("input[@name='no_enddate']:checked").val() == 'yes') {
			$('#end_date').attr('disabled', 'disabled');
			$('.end_date').hide();
		}else {
			$('#end_date').attr('disabled', '');
			$('.end_date').show();
		}
		$('.enddatecheck').click(function() {
			if ($("input[@name='no_enddate']:checked").val() == 'yes') {
				$('#end_date').attr('disabled', 'disabled');
				$('.end_date').hide();
			}else {
				$('#end_date').attr('disabled', '');
				$('.end_date').show();
			}
		});
	});
	</script>
	<?php
	if ($no_enddate == 1) {
		echo '<div class="inputgroup">Yes<input id="enddate_yes" class="radio enddatecheck" type="radio" name="no_enddate" value="yes" checked="checked" />No<input type="radio" name="no_enddate" id="enddate_no" value="no" class="radio enddatecheck" /></div>';
	}else {
		echo '<div class="inputgroup">Yes<input class="radio enddatecheck" type="radio" id="enddate_yes" name="no_enddate" value="yes" />No<input class="radio enddatecheck" type="radio" name="no_enddate" value="no" id="enddate_no" checked="checked" /></div>';
	}
	?><br/><br/>
        <span class="end_date">
	<label for="end_date">End Date:</label><br/><input name="end_date" id="end_date" class="date_pick" type="text" value="<?php echo $end_date; ?>" /><br />
        </span>

Link to comment
https://forums.phpfreaks.com/topic/209978-strange-behaviour-from-checkboxes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.