I am using several buttons on my page of the same class. Here is an example:
<button id="YES" type="button" class="btn btn-lg btn-primary" data-toggle="button" name="yesPowerwash">YES</button>
I believe I can determine whether or not the button has been toggled with the following (please correct me if I am wrong):
$('[name="noPowerwash"]').hasClass('active')
I cannot figure out how to post the state (active vs inactive) as part of the form submission.
Any help would be greatly appreciated.
This is just part of the value field in bootstrap. i.e This is an example for a radio button you can change it to a regular button by just looking at the documentation here.
<label class="radio-inline">
<input type="radio" id="buycheckbox" value="buy" name="radiogroup" required>Buy
</label>
So the value here is buy
. Where ever you post too, let's say another php page you can check to see if the radiogroup button was clicked as buy. i.e
if($_POST['radiogroup'] == 'buy')
Your html:
<form id="contact-form" method="POST" action="form-handling.php">
<div class="success"> Contact form submitted! <strong>We will be in touch soon.</strong> </div>
<fieldset>
<div>
<label class="name">
<input type="text" value="name">
<br>
<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label>
</div>
<div>
<label class="phone">
<input type="tel" value="Telephone">
<br>
<span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span> </label>
</div>
<div>
<label class="email">
<input type="email" value="Email">
<br>
<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span> </label>
</div>
<div>
<label class="message">
<textarea>Message</textarea>
<br>
<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>
</div>
<div class="buttons-wrapper"> <a class="btn btn-1" data-type="reset">Clear</a> <a class="btn btn-1" data-type="submit">Send</a></div>
</fieldset>
</form>
form-handling.php
name =$_POST['name'];
tele = $_POST['Telephone']
..... etc
Now just add the button label/input to the form
Try this to do the toggleing its just another example.
It doesn't matter if the type = radio or check box its the div that gives the look.
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input name="year" value="2011" type="radio">2011
</label>
<label class="btn btn-default">
<input name="year" value="2012" type="radio">2012
</label>
<label class="btn btn-default">
<input name="year" value="2013" checked="" type="radio">2013
</label>
</div>