What I need to do is: I have a simple input field, and below that I have a dropdown list with options: Checkbox and Radio. The user needs to write something in the input field and select the type. For example:
Input field: One, Two, Three
Radio
and the outcome will be 3 radio buttons with titles One Two Three. The problem here is that I don't know how to separate the inputs (they have to be separated by a comma). So far, I managed to get this, but as you can see, I'm not getting what I need to get.
I tried to find solution but I'm kinda new so I don't know how to do it. Btw, it needs to be done in Javascript and HTML only. Here is my code
function create() {
var items = document.getElementById("items")
items = items.value
var type = document.getElementById("type")
type = type.value
var result = document.getElementById("result")
result.innerHTML += "<input type='" + type + "'>" + items
}
<h2>Form</h2>
<div>
<span>Items: </span><input type="text" id="items">
</div>
<div>
<span>Type: </span>
<select id="type">
<option>Checkbox</option>
<option>Radio</option>
</select>
</div>
<button onclick="create()">Create</button>
<div id="result"></div>