Forum OpenACS Q&A: Checked radio.

Collapse
Posted by Jorge Couchet on
Hi,

One question: How do you set with ad_form a checked radio?

If I use the "html" tag with "checked" as follow:

{RB:text(radio) {label "L"} {options {{"Y" 1} {"N" 2}}} {value {"N" 2}} {html {checked checked}}}

The last option (in the example "N") is checked. Is there a way to set a checked option independent from its position in the "options" list?

Thanks in advance for the help.

Regards,

Jorge.

Collapse
2: Re: Checked radio. (response to 1)
Posted by Dave Bauer on
Hi,

You should not set the value in the element delcaration.

You should set the value in the

-on_request or -new_request or -edit_request code blocks.

To do that you should set the variable named for the form element to the correct value.

In your case something like this:

-on_request {
set RB "2"
}

This will check whatever option has the value of "2".

Collapse
3: Re: Checked radio. (response to 2)
Posted by Jorge Couchet on
Hi Dave!

Thanks, it works perfectly!

Regards,

Jorge.