I created a form in which I need to use these two tags. My problem is that every time the user clicks on it, the form is submitted. I used onclick="return false" as follows, but the values are not sent in the url Query.
<div class="btn-group d-flex justify-content-center col-11 mx-auto" role="group">
<button type="radio" onclick="return false" name="type" value="rent" class="btn btn-lg btn-light pr-4 pl-4" id="left">YES</button>
<button type="radio" onclick="return false" name="type" value="sale" class="btn btn-lg btn-light pr-4 pl-4" id="right">NO</button>
</div>
<div class="col-11 mx-auto">
<button class="btn btn-block btn-danger">Submite</button>
</div>
<button type="radio"
Radio buttons are input
elements, not button
elements. They are also empty/void elements which can't have children, so use a label
element instead.
<input type="radio" name="type" value="rent" class="btn btn-lg btn-light pr-4 pl-4" id="left"> <label for "left">Yes</label>
Note that screen reader software tends to read out content in all-caps letter-by-letter. Write in normal sentence case and use the CSS text-transform
property to present it in upper-case instead.
<input type="radio" name="type" value="yes" class="btn btn-lg btn-light pr-4 pl-4" id="left"> <label for "left">Yes</label>
the button does not contain the value property to show the radio type input fields use input type fields.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.