Reputation: 327
I need to make a group of 2 radio buttons in my javascript for my web app. So far I have this code:
//radio buttons start
var AddRadio = function(options){
var _dom_element = document.createElement("radio");
for ( var i = 0; i < options.length; i++ ) {
var _option = document.createElement("radio");
_option.value = options[i];
_option.innerHTML = options[i];
_dom_element.appendChild(_option);
};
this.getDomElement = function() {
return _dom_element;
}
}
//radio buttons end
var _temp_radio = new AddRadio(['Max Temp', 'Min Temp']);
container_element.appendChild(_temp_radio.getDomElement());
The problem is that only the 'Max Temp' and 'Min Temp' strings show up, the actual radio buttons are not there. Thanks If you can help in any way.
Upvotes: 0
Views: 51
Reputation: 612
radio buttons are
<input type="radio">.
You are creating a
<radio>
tag instead.
Upvotes: 1
Reputation: 10104
Use an <input type="radio"/>
tag.
e.g.
var option = document.createElement('input');
option.type = 'radio';
http://www.w3schools.com/html/html_forms.asp
Upvotes: 0