How do I change the position of a radio button in html? - html

I am programming a webpage that uses a series of radio buttons and drop down menus to change the data that is displayed on the screen. Each radio corresponds to one of the drop down menus and I want to line them up but I can't figure out how to get the third one to appear to the right of the other two instead of below them. Can anyone help?
Here's my code:
<form action="" style="float: left">
<input type="radio" name="yearLessGreaterOption" value="<" onchange="setYearLessGreaterFilter(this.value)"><
<input type="radio" name="yearLessGreaterOption" value="=" onchange="setYearLessGreaterFilter(this.value)" checked>=
<input type="radio" name="yearLessGreaterOption" value=">" onchange="setYearLessGreaterFilter(this.value)">>
</form>
<form action="">
<input type="radio" name="roundLessGreaterOption" value="<" onchange="setRoundLessGreaterFilter(this.value)"><
<input type="radio" name="roundLessGreaterOption" value="=" onchange="setRoundLessGreaterFilter(this.value)" checked>=
<input type="radio" name="roundLessGreaterOption" value=">" onchange="setRoundLessGreaterFilter(this.value)">>
</form>
<form action="">
<input type="radio" name="goalsH1LessGreaterOption" value="<" onchange="setGoalsH1LessGreaterFilter(this.value)"><
<input type="radio" name="goalsH1LessGreaterOption" value="=" onchange="setGoalsH1LessGreaterFilter(this.value)" checked>=
<input type="radio" name="goalsH1LessGreaterOption" value=">" onchange="setGoalsH1LessGreaterFilter(this.value)">>
</form>
Here's a picture of the page in question:

Is there a reason you want them in form tags? If you remove the tags, they will appear aligned. Otherwise, adding style="float:left;" to the other form tags will do the trick.

In your case, adding the style="float: left" on the other forms should do what you want.

Related

How to create a select input with the options horizontally aligned?

I basically want to create a select element, where the options are displayed next to each other horizontally. Like this:
How can I implement this design?
Using a basic form a radio button would be one way to do it and then hide the actual input using css while keeping the label
Hide radio button while keeping its functionality
then you are just styling the labels how you want them
<form action="form action goes here">
<input type="radio" value="1">
<label for="1">1</label>
<input type="radio" value="2">
<label for="2">2</label>
<input type="radio" value="3">
<label for="3">3</label>
<input type="radio" value="1">
<label for="3">3</label>
...and so on
</form>

Radio Button won't check in Plain HTML

The web page I am working on requires a few html radio buttons at the bottom of a large picture. I included the id the type the name. But when I load the page, none of the radios will select.
<fieldset>
<form id="radio" action="" method="GET">
<input id="pic-1" type="radio" name="jumbotron-radio" value="1">
<input id="pic-2" type="radio" name="jumbotron-radio" value="2">
<input id="pic-3" type="radio" name="jumbotron-radio" value="3">
</form>
</fieldset>

Html 5 required on radio button wil not reset

Why won't an html5 required on radio button group reset with form reset button if it was selected. for example you have a radio button group in a form with the html5 required set if you select one of the radio buttons then click the reset form button it doesn't reset the radio button group required validation so even though the form was reset. So basically you click submit button without selecting anything the radio buttons are given an outline in red then you select one and click reset you are then able to submit the form without selecting a radio button? any help on why it does this would be greatly appreciated. I may misunderstand how its supposed to work.
Simple test
<html>
<form>
<input type="radio" name="test" required>
<input type="radio" name="test" required>
<input type="submit" value="submit">
<input type="reset" value="cancel">
</form>
</html>
It is because you are using same name for the radio buttons.If you give the same name only one radio button of the can be checked.And so it passes the Validation
Example : Different name for radio buttons.
<form>
<input type="radio" name="test" required>
<input type="radio" name="test2" required>
<input type="submit" value="submit">
<input type="reset" value="cancel">
</form>
Example : Same name for radio buttons.
<form>
<input type="radio" name="test" required>
<input type="radio" name="test" required>
<input type="submit" value="submit">
<input type="reset" value="cancel">
</form>
You need to give them different value attributes (but the same name so it's clear that those are two different options for the same "question" and only one of them should be selectable):
<html>
<form>
<input type="radio" name="test" value="1" required>1
<input type="radio" name="test" value="2" required>2<br>
<input type="submit" value="submit">
<input type="reset" value="cancel">
</form>
</html>

Creating a simple radio buttons form with greyed-out buttons

In the following code:
<form>
<input type="radio" style="disabled:true">Alpha<br>
<input type="radio" style="enabled:false">Beta<br>
<input type="radio">Gamma<br>
</form>
1) Why is it allowing me to select more than one radio button at a time?
2) How to I "grey out" specific radio buttons? The "enabled" and "disabled" attributes do not seem to be working.
To make a group of radio buttons, give them all the same name:
<form>
<input type="radio" name="group1">Alpha<br>
<input type="radio" name="group1">Beta<br>
<input type="radio" name="group1">Gamma<br>
</form>
Demo
To disable a radio button, use the disabled attribute in its tag:
<form>
<input type="radio" name="group1">Alpha<br>
<input type="radio" name="group1">Beta<br>
<input type="radio" name="group1" disabled>Gamma<br>
</form>
Demo
Disabled is not a CSS attribute so it is not defined within the style attribute.
As commented above you can also wrap the <input> in a <label> tag like so:
<form>
<label><input type="radio" name="group1">Alpha</label><br>
<label><input type="radio" name="group1">Beta</label><br>
<label><input type="radio" name="group1" disabled></label>Gamma<br>
</form>
Or you can link the label with the inputs id:
<label for="alpha">Alpha</label>
<input type="radio" name="group1" id="alpha">
Then the user can click on the text instead of just the radio button.
Demo
The disabled attribute isn't a css style. You disable an input like this:
<form>
<input type="radio" name="radGroup">Alpha<br>
<input type="radio" name="radGroup" disabled>Beta<br>
<input type="radio" name="radGroup">Gamma<br>
</form>
notice also the name attribute. This will prevent multple radio buttons been selected at once. Each input in the group must share the same name
DEMO
a group of radiobuttons must have the same same to select only one:
use the html disabled attribute to disable a radio <input type="radio" disabled>
so your solution would be:
<form>
<input type="radio" name="rb1">Alpha<br>
<input type="radio" name="rb1">Beta<br>
<input type="radio" name="rb1" disabled>Gamma<br>
</form>

change form action with radio buttons

I would like to implement something similar to a google search with radio buttons. Depending on the radio button selected, would change the type of search (search,images,video, etc).
Right now I have:
<div id ="searchtext">
<form method="get" id ="searchbox" action="http://www.google.com/search"/>
<input type="text" name="q" size="30" class="searchtext" maxlength="255" value="" />
<input type="image" value="Search" class="searchbutton" src="images/searchbar/searchbutton.png"/>
<br/>
</div>
<div id="radiosearch">
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://www.google.com/search?q=';" checked="checked"/> Web
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://images.google.com/images?q=';"/>Images
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://maps.google.com/maps?hl=en&tab=wl?q=';"/>Maps
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://www.youtube.com/results?q=';"/>Youtube
<span class = "class1">
Change Theme
</span>
</div>
However, clicking on the radio boxes is not changing the form action. Any Ideas?
Try
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://www.google.com/search?q=';" checked="checked"/> Web
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://images.google.com/images?q=';"/>Images
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://maps.google.com/maps?hl=en&tab=wl?q=';"/>Maps
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://www.youtube.com/results?q=';"/>Youtube