I am trying to code a form that creates a custom sentence based on the inputs a user selects. For example, my form has one written inputs and two dropdowns. I want this data added to my innerHTML. Say I wanted to create a custom sentence about a dog the layout would look like this:
My dog's name is (value from input 1). (Value from dropdown 1) loves to play fetch. My dog is (value from dropdown 2).
function sentence() {
document.getElementById("s1").innerHTML = "My dog's name is (value from input 1). (Value from dropdown 1) loves to play fetch. My dog is (value from dropdown 2).";
}
table,
td,
th {
margin-left: auto;
margin-right: auto
}
.display {
display: flex;
align-items: center;
justify-content: center;
}
p {
text-align: center;
}
<table>
<tr>
<td> <input type="text" placeholder="Your Dog's Name" name="name" maxlength="100"></td>
<td>
<select name="gender">
<option value="He">He</option>
<option value="She">She</option>
</select>
</td>
<td>
<select name="size">
<option value="Big">Big</option>
<option value="Medium">Medium</option>
<option value="Small">Small</option>
</select>
</td>
</table>
<br>
<hr>
<br>
<p id="s1">
</p>
<br>
<div class="display">
<button onclick="sentence()"> Button </button>
</div>
<p id="s1">
</p>
document.getElementById('theid').value. All you need to do is changenametoid(nameis for forms that get sent to the server).