Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript updating a form field from selections Re: updating a form field from selections

#57935
akeenlabs
Participant

Let’s simplify this a little bit. Disregarding the actual implementation, here is what I gather you are looking for:

Start with a series of radio buttons and a text box.

As each radio button is selected, it copies it’s own value into a different textbox.
-or-
When the page is submitted, copy the value of the currently selected radio button into the textbox.

I’m only going to solve the first (if you’d like the second I could do that too). So, here it goes:

Code:














I’m using jQuery (a JavaScript library that helps with browser incompatibilities and DOM manipulation), so if you’ve never used it before some of this may look a little foreign and I recommend checking it out: http://www.jquery.com. Basically you just need to attache an event to each radio button that fires when that radio button’s ‘checked’ status changes. If the radio button is checked, then you should copy something into the textbox.

I hope this is what you’re looking for. If not, help narrow in on it and we’ll give it another shot. :D