Problem: I have not been able to get the value of a radiobutton or value in a textbox.
From trial and error, I found that the following gives me access to the information in div gender1
I could not figure out how to get the value of gender or age. I tried appending .value/.value(), using the id attribute, etc. I also tried various methods from a related question on stack overflow (Get Radio Button Value with Javascript), but had little success.
var checkedRadio = document.querySelectorAll('.w3-container')[0]
.querySelectorAll('#box')[0]
.querySelector('#gender1');
console.log( checkedRadio );
<body>
<div class="w3-container">
<div id="box" style="width:600px;height:650px;padding:10px;border:2px solid black;">
<h5><b>Age (years):</b></h5>
<div id="age">
<input type="number" name="age1">
<br>
</div>
<div id="gender1">
<h5><b>Male or Female?</b>:
<input type="radio" id="r1" name="gender" value="Male"> Male
<input type="radio" id="r2" name="gender" value="Female"> Female
</h5>
</div>
</div>
</div>
</body>