After creating an HTML form, I encountered an issue where only one selected item was displayed in the text field. Can anyone help me solve this problem so that multiple names can be printed in the textfield?
function myFun(extras) {
document.getElementById("check").value = extras;
}
<fieldset>
<legend>Extras</legend>
<p><label class="choice">
<input type="checkbox" name="extras" value="baby" onclick="myFun(this.value)">
Baby Seat
</label></p>
<p><label class="choice">
<input type="checkbox" name="extras" value="wheelchair" onclick="myFun(this.value)">
Wheelchair Access
</label></p>
<p><label class="choice"> <input type="checkbox" onclick="myFun(this.value)" name="extras" value="tip">
Stock Tip
</label></p>
<input type="text" id="check">
</fieldset>
Don't stress out about it and keep on coding!