Reputation: 730
Trying to get a value from this checkbox but it's not working..
Should be a simple yes or no .. however nothing is happening .. always defaults to the else statement.
<form id="edit_donor_form" action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post" name="switch">
<label class="switch">
<input type="checkbox" name="switchq" value="Yes" >
</label>
<input name="submit" type="button" value="submit" />
</form>
<?php
if(isset($_POST['submit']) && $_POST['switchq'] == 'Yes') {
echo "Hover On.";
}
else {
echo "Hover Off";
}
?>
Upvotes: 0
Views: 64
Reputation: 1371
If You dont't want change input type="button" to type="submit", You can add:
<input name="submit" type="button" value="submit" onclick="document.getElementById('edit_donor_form').submit();" />
Upvotes: 0
Reputation: 3552
Because your form not has submit botton, the input type that you used was button
you need to change it to submit
<input name="submit" type="submit" value="submit" />
Upvotes: 2