Hello,
I have a form with a radio button with 3 different choices. One of them allows to open a separate section with more fields. However, if this field is opened, I need one of the text value already enetered by the user to be automatically populated.
I am using innerHTML to update this value. This is working fine if the radio button is checked and the hidden section is already open only. But I want this valued to be while it’s closed as well. Here is the sample code below. Any help/suggestion will be appreciated.
function add_protocol() {
document.getElementById(‘p1’).innerHTML = document.myform.Text2.value;
}
<input rel=”Info” name=”Text17″ type=”radio” value=”rad1″ onclick=”add_protocol()”>Choice1<br>
The segment of the code above doesn’t update the value in the hidden section. However, if select the radio button and make that hidden field open, the following code updated the value dynamically as soon as I add/change the value on Text2.
function add_it() {
if (document.aarform.Text17[0].checked) {
document.getElementById(‘p1’).innerHTML=document.myform.Text2.value;
}
}
Is there any way I can update the section automatically even if it is not openning until the radio button is clicked?
Thanks in advance…