/    Sign up×
Community /Pin to ProfileBookmark

Dynamically update the form field value

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…

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @web_coder spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...