Tojó Tojó - 2 months ago 7
jQuery Question

Radio form value not showing up?

I am a still a newbie so sorry for any mistakes. I have searched a lot and couldn't solve my problem. I dynamically created this radio input:

var radio_input = document.createElement('input');
radio_input.type = "radio";
radio_input.name = "test_input"
radio_input.value = "teeest";
radio_input.appendChild(my_form);


However I can't get the input value to show up. I get something similar to this:
test_input (but one instead of 3)

I want to have "test" written in the left side of the input... Can someone help me?

Answer

As saied @RobertoLinare in the comment, then you can create a div and put the label there:

var radio_input = document.createElement('input');
var label = document.createElement('label');
var div = document.createElement('div');

radio_input.type = "radio";
radio_input.name = "test_input"
radio_input.value = "teeest";

label.innerHTML = "Label";
document.getElementById("my_form").appendChild(div);
div.appendChild(label);
div.appendChild(radio_input);
<form id="my_form">

</form>