How to populate a select list

I’m creating a simple ‘Yes/No’ select droplist. I thought the select
tag accepted a hash. But, it doesn’t show any items when I view it.
This is the code in Markaby 0.5.

select_tag( ‘work_order’, ‘warranty_work_ny’,{“Yes” => “Y”, “No” =>
“N”})

There must be an obvious error in there somewhere, I’m just not seeing
it.

Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

Larry K. wrote:

I’m creating a simple ‘Yes/No’ select droplist. I thought the select
tag accepted a hash. But, it doesn’t show any items when I view it.
This is the code in Markaby 0.5.

select_tag( ‘work_order’, ‘warranty_work_ny’,{“Yes” => “Y”, “No” =>
“N”})

There must be an obvious error in there somewhere, I’m just not seeing
it.

Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

try

select_tag(name, option_tags = nil, options = {})
but
select(object, method, choices, options = {}, html_options = {})
try
select_tag( ‘warranty_work_ny’,{“Yes” => “Y”, “No” => “N”})

You want the select helper, not select_tag, since you are tying it to
your work_order.warranty_work_ny method. This helper accepts an array of
arrays for the choices, not a hash.

Here’s how you do it…

select(‘work_order’, ‘warranty_work_ny’, [[“Yes”,“Y”],[“No”,“N”]])

c.

Larry K. wrote:

I’m creating a simple ‘Yes/No’ select droplist. I thought the select
tag accepted a hash. But, it doesn’t show any items when I view it.
This is the code in Markaby 0.5.

select_tag( ‘work_order’, ‘warranty_work_ny’,{“Yes” => “Y”, “No” =>
“N”})

There must be an obvious error in there somewhere, I’m just not seeing
it.

Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

On Oct 16, 1:44 am, “Larry K.” [email protected] wrote:

“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

From a user interface perspective, a ‘select’ for a yes/no question is
a bad idea.

For a boolean state object I suggest one of two approaches…

  1. A checkbox or
  2. two radio buttons.

In your case, it sounds like you really need to put in a checkbox

I use the radio button approach when the states match to a small set of
mutually exclusive states that don’t neatly map to a true/false.
Things like ‘gender’ are a good example.

_Kevin

On 16 Oct 2006, at 14:48, _Kevin wrote:

On Oct 16, 1:44 am, “Larry K.” [email protected] wrote:

I’m creating a simple ‘Yes/No’ select droplist. I thought the select
tag accepted a hash. But, it doesn’t show any items when I view it.
This is the code in Markaby 0.5.

select_tag( ‘work_order’, ‘warranty_work_ny’,{“Yes” => “Y”, “No”
=> “N”})

There must be an obvious error in there somewhere, I’m just not
seeing it.

select_tag takes: name for params, options for popup, html options.
So you have an extra argument slipped in there, and you should really
use options_for_select to build the options string. try:

select_tag(:warranty_work_ny, options_for_select({“Yes” => “Y”, “No”
=> “N”}))

(typed into mail, apologies in advance for the errors)

From a user interface perspective, a ‘select’ for a yes/no question is
a bad idea.

From the survey design PoV, any binary (Yes/No) question has four
possible and appropriate responses:

Yes;
No;
Don’t know;
not applicable.

Plus also:

Not Answered.

For a boolean state object I suggest one of two approaches…

  1. A checkbox or
  2. two radio buttons.

In your case, it sounds like you really need to put in a checkbox

I use the radio button approach when the states match to a small
set of
mutually exclusive states that don’t neatly map to a true/false.
Things like ‘gender’ are a good example.

Most binary survey questions fall into the same camp. From the UI
perspective, popups/dropdowns are biased towards the first option,
the one that shows by default.

Paul