How can I make radio buttons next to each other? - html

I got the problem that i want to have 2 radiobuttons next to each other. but one below the other.
<div class="backgroundOverlay cShow" ng-show="isShownUser">
<div class="dropDown positionPopUp inpuBlock" id="add">
<div class="inputBlock">
<h1 class="popupTitle">{{titlePopup}}</h1>
<div>
<div class="cClearFloat cInputSpace">
<input placeholder="login" ng-model="currentUser.login">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="Vorname" ng-model="currentUser.Vorname">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="Nachname" ng-model="currentUser.Nachname">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="password" ng-model="currentUser.password">
</div>
<div class="cClearFloat cInputSpace cRadioAdmin">
<label><input type="radio" name="Admin">Ja</label>
<label><input type="radio" name="Admin">Nein</label>
<div class="cClearFloat cButtonsUser">
<button class="cButtonSpeichern" ng-click="showAlert()">Speichern</button>
<button class="cButtonAbbrechen" ng-click="isShownUser = false">Abbrechen</button>
</div>
can someone help me pls.

You need to understand the difference between inline elements and block elements.
Using a div instead of your label to wrap the input will do the job.
Like this:
<div><input type="radio" name="Admin">Ja</div>
<div><input type="radio" name="Admin">Nein</div>
You could also use the css, like this:
<label style="display:block"><input type="radio" name="Admin">Ja</label>
<label style="display:block"><input type="radio" name="Admin">Nein</label>
Similarly you can use display:inline to force inline(in case some other css is affecting this)

Related

How to target div class within a form?

I have this html which i want to target with css. The problem is that i can't find the right css selector.
The problem is that . entry-content doesn't work. Neither does.event-manager-form. The form itself is a Wordpress event manager form and want to style in with, amongst others,, border-radius
<div class="entry-content">
<form action="/post-an-event/" method="post" id="submit-event-form" class="event-manager-form" enctype="multipart/form-data">
<fieldset>
<label>Your account</label>
<div class="field
account-sign-in">
You are currently signed in as <strong>Bla bla</strong>. <a c class="button" href="...">Sign out</a>.
</div>
</fieldset>
<!-- Event
Information Fields -->
<h2 class="section-title">Event Details</h2>
<fieldset class="fieldset-event_title">
<label for="event_title">Event Title<span class="require-field">*.
</span></label>
<div class="field required-field">
<input type="text" class="input-text event_title" name="event_title" id="event_title" placeholder="Event title" attribute="" value="" maxlength="" required />
</div>
</fieldset>
<fieldset class="fieldset- event_online">
<label for="event_online">Online Event<span class="require-
field">*</span></label>
<div class="field
required-field">
<label><input
type="radio" name="event_online" id="event_online"
attribute="" value="yes" /> Yes</label>
<label><input
type="radio" name="event_online" id="event_online"
attribute="" value="no" /> No</label>

Using Twitter Bootstrap to line up radio button answers

With Twitter Bootstrap 3.3.7, I am trying to line up multiple questions that have inline radio button answers and have the radio buttons for all questions line up to be displayed nicer for end users.
If this is on a Extra small device, I want the radio buttons to be on the next line.
The trouble I am having is that applying col-sm-6 (or any column size) seems to not work as I expect. The help-block doesn't fully go to the next line, it's stuck under the radio buttons.
I'm looking to be able to use proper Twitter Bootstrap form syntax. Is this possible with the form syntax, or does this require doing it with their own rows/cols?
An example of a question: JSFiddle https://jsfiddle.net/y8j5f0of/
<div class="row">
<div class="form-group">
<label class="col-sm-6">This is an example question</label>
<div class="col-sm-6">
<label class="radio-inline">
<input type="radio" name="answer1" value="Yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="answer1" value="No"> No
</label>
</div>
<span class="help-block">This is an example help block that has a lot of text that should start under the question instead of the answer.</span>
</div>
</div>
Answers are lined up, but the output isn't flowing properly.
If I remove the col-sm-6, everything flows as expected but the answers aren't lined up. Also, this doesn't allow the radio buttons to go to their own line for Extra small device.
JSFiddle https://jsfiddle.net/nz36k74o/1/
<div class="row">
<div class="form-group">
<label>This is an example question 1 that is longer than question 2</label>
<label class="radio-inline">
<input type="radio" name="answer1" value="Yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="answer1" value="No"> No
</label>
<span class="help-block">This is an example help block that has a lot of text that should start under the question instead of the answer.</span>
</div>
</div>
Output
The help block should really be in a new row. If it is supposed to be underneath the other content, then its not part of the row. That's the basis of the Bootstrap grid system. A basic question block should look like this:
<div class="form-group">
<div class="row">
<label class="col-sm-6">This is an example question 1 that is longer than question 2</label>
<div class="col-sm-6">
<label class="radio-inline">
<input type="radio" name="answer1" value="Yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="answer1" value="No"> No
</label>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span class="help-block">This is an example help block that has a lot of text that should start under the question instead of the answer.</span>
</div>
</div>
</div>
Check out the fiddle (sorry onlyhad time to do one)
Here is one solution to align the question correctly. It adds in some extra html tags but I believe it solves your issue.
This is the updated fiddle.
https://jsfiddle.net/nz36k74o/3/
<div class="form-group">
<label class="col-sm-6">This is an example question</label>
<div class="col-sm-6">
<label class="radio-inline">
<input type="radio" name="answer1" value="Yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="answer1" value="No"> No
</label>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<span class="help-block">This is an example help block.</span>
</div>
</div>

How to link fancy radio buttons to same ID?

I would like to use these funky radio buttons though the radio buttons have an id=radio1, id=radio2, id=radio3 etc
I would like all of them to have id-radio1 so it writes the result to radio1 in the database:
Here is how I have normal radio buttons working in the past using the same id and they toggle between one another:
<div class="form-group col-md-12">
<label class="control-label form-check-inline">Gender</label>*
<div class="form-group">
<input type="radio" id="Gender" name="Gender" value="M" required="required" /><label class="control-label">Male</label>
<input type="radio" id="Gender" name="Gender" value="F" required="required" /><label class="control-label">Female</label>
</div>
</div>
$Gender=$_POST["Gender"];
INSERT INTO [dbo].[SubmissionsTBL]
[Gender]
VALUES
(,'".trimText($Gender)."')
Though, with the funky radio buttons chaning from this:
<div class="funkyradio">
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio" id="radio1" />
<label for="radio1">Male</label>
</div>
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio" id="radio2"/>
<label for="radio2">Female</label>
</div>
</div>
to this doesn't work - it doesn't allow me to toggle radio buttons:
<div class="funkyradio">
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio" id="radio1" />
<label for="radio1">Male</label>
</div>
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio" id="radio1"/>
<label for="radio2">Female</label>
</div>
</div>
What is stopping the toggle?
Thank you!
TL;DR: Due to the id and name attribute having the same value in your first example, I believe you may be confusing the two. With the database communication code you put up, it's grabbing the name="Gender" and not the id="Gender".
Additional information about id and class though you might find useful as an internet programmer:
The id attribute can only apply to one element per HTML document. I would suggest using the class attribute instead. The main difference between and id and a class is that a class can be applied to multiple elements.
Here is a working solution to the code you provided:
<div class="funkyradio">
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio1" id="radio1" class="radio_grp1"/>
<label for="radio1">Male</label>
</div>
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio1" id="radio2" class="radio_grp1"/>
<label for="radio2">Female</label>
</div>
</div>
I used the class .radio_grp1 as the name so that you know that you're referring to a group of radio buttons rather than just one.
Moreover, if you're using a library like bootstrap, it's very common that an element will already have an assigned class. To solve this issue, you can assign a single element multiple classes by adding a space in the string following the class attribute like so:
<input type="radio" name="radio" id="radio2" class="radio radio_grp1"/>
Hope this was useful!
Your code should be changed to something like this. the radio button's name is what is submitted to the back end, and the id is used for front-end things like label association.
id's should always be unique.
<div class="funkyradio">
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio1" id="radio1" />
<label for="radio1">Male</label>
</div>
<div class="funkyradio-primary col-md-6">
<input type="radio" name="radio1" id="radio2"/>
<label for="radio2">Female</label>
</div>
</div>
If by toggling, you mean the normal behavior of radio buttons, then that happens whenever all the radio buttons in the group have the same name.

jQuery Mobile: How do you write multiple horizontal radio groups into one fieldset with headings/legends?

Using jQuery Mobile and Horizontal radio field sets as show at:
http://demos.jquerymobile.com/1.4.3/checkboxradio-radio/#Horizontalgroup
What's the proper way to write two (or many) different radio groups into a single fieldset (if possible). Writing multiple horizontal radio groups into a single fieldset seems strange to me. I'm not sure if I'm using all the elements properly.
<div data-role="page" id="test">
<div data-role="content">
<div data-role="fieldcontain">
<div class="ui-body ui-body-a ui-corner-all">
<fieldset data-role="controlgroup" data-theme="a" data-type="horizontal">
<legend>FieldSet Name:</legend>
<div class="ui-field-contain">
<legend>Question 1:</legend>
<input type="radio" name="radio-choice-1" id="radio-choice-1-no" value="1">
<label for="radio-choice-1-no">No</label>
<input type="radio" name="radio-choice-1" id="radio-choice-1-yes" value="2">
<label for="radio-choice-1-yes">Yes</label>
</div>
<div class="ui-field-contain">
<legend>Question 2:</legend>
<input type="radio" name="radio-choice-2" id="radio-choice-2-no" value="1">
<label for="radio-choice-2-no">No</label>
<input type="radio" name="radio-choice-2" id="radio-choice-2-yes" value="2">
<label for="radio-choice-2-yes">Yes</label>
</div>
</fieldset>
</div>
</div>
</div>

Float right check boxes, buttons and inputbox

I reckon it must be fairly simple but i can't seem to figure out how to get my floats right. The picture shows what i want vs what i have. If you provide an answer please provide the logic also. thanks.
<div id="racks" style="overflow:auto">
<div id="selStat">
<p>No station selected</p>
</div>
<hr id="hrtest">
<div id="rackAction">
<p>Choose the type of card, then select which action to perform.</p>
<div id="radio">
Type:
<div class="fr">
<input type="radio" id="radioS" name="radio"><label for="radioS">S</label>
<input type="radio" id="radioP" name="radio"><label for="radioP">P</label>
<input type="radio" id="radioV" name="radio"><label for="radioV">V</label>
</div></div>
<p>Cardnumber: <input id="cardNum" class="fr" type="number" size="1"/> </p>
<p>Action:
<div class="fr">
<button onClick="addRack()" type="button">Add</button>
<button onClick="deleteRack()" type="button">Delete</button>
</div></p>
</div>
</div>
CSS is as follow:
.fr{
float:right;
}
Syntactically, you can't have a div inside of a p tag. On that topic, check this SO Question. To get the elements on the same line, you can place the "Action" text in a seperate div, and float it left.
The HTML:
<div id="racks" style="overflow:auto">
<div id="selStat">
<p>No station selected</p>
</div>
<hr id="hrtest">
<div id="rackAction">
<p>Choose the type of card, then select which action to perform.</p>
<div id="radio">
Type:
<div class="fr">
<input type="radio" class="margin-bottom" id="radioS" name="radio"><label for="radioS">S</label>
<input type="radio" class="margin-bottom" id="radioP" name="radio"><label for="radioP">P</label>
<input type="radio" class="margin-bottom" id="radioV" name="radio"><label for="radioV">V</label>
</div>
</div>
<p>Cardnumber: <input id="cardNum" class="fr" type="number" size="1"/> </p>
<div class="fl">Action:</div>
<div class="fr">
<button onClick="addRack()" type="button">Add</button>
<button onClick="deleteRack()" type="button">Delete</button>
</div>
</div>
</div>
The CSS:
.fr{
float:right;
}
.fl {
float:left;
}
.margin-bottom {
margin-bottom:10px;
}
The fiddle.
Edit:
As per the comments, you can add a class to the radio buttons in question, and add additional margins or padding to the bottom of the radio buttons. I have updated the code to include the class additions and the CSS.