Scripting help

It’s been a really, really long time since I programmed anything, and I can’t seem to put the disparate elements together to form a whole Javascript. I’m hoping one of my readers can help me. Here’s what I need to do:

I have a group of photos in a table, each assigned a radio button. The user is going to choose the photo s/he likes best and then click the submit button, which will send an email. The subject of the email will be populated with the value of the radio button chosen. I’m naming all the photos and radio buttons the same, e.g., 0001, 0002.

Like I said, I have the elements down. I can’t seem to put a script together that passes the value of the radio button into the right place, mostly because, uh, it’s been four years since I last wrote a script. The syntax is what is giving me problems.

Any help would be greatly appreciated.

This entry was posted in Work. Bookmark the permalink.

3 Responses to Scripting help

  1. Brian says:

    The trick with radio buttons is to remember that all the buttons have the same name… but they have different values.

    So you’ll have:

    <input type=”radio” name=”picture” value=”0001″>
    <input type=”radio” name=”picture” value=”0002″>

    …And so on. Then you can access the values with:

    document.form.picture[0]
    document.form.picture[1]

    …Like that.

  2. Brian says:

    Also you can get their “selected” status with:

    document.form.picture[0].checked

    …which is a boolean (e.g. “=true”).

  3. Thanks, Brian, because that’s one of the mistakes I’m now correcting. I forgot that about radio buttons. Man, what a pain I’ve been saved, too. There may be several hundred of these buggers to choose from.

Comments are closed.