views:

48

answers:

1

Hello,

I have a slight problem with getting the options within the select tag. Some background information; This is a report, and as such the select options will vary depending on what is stored on the DB depending on some conditions. So, I'm using observe field to get the selected option, BUT, I need to get all the options because I want render that same report with a) the selected option that was chosen the first time and the remaining ones.

select "price", "desc", @desc, {:prompt => 'All'}

I'm obviously observing the field, to display the result, so the variable @desc is the hash with the all the values.

Can you help me get hash to be sent to the controller, and how can I have the selected option selected in the hash to be sent back to the view....

Cheers

+1  A: 

You have the options already, so where'd you get them? Are they report specific? If so, send the report_id back so you can look all of them up again, then you can select the selected one.

You can't (easily) get all of the options in a select list. Technically, you could write a javascript function that would grab all of them and send them as parameters. Or, you could write them out as a hidden field and submit that with the request, but both of those ways are ugly.

wesgarrison
Okay, so basically now I'm doing the SQL again, but I need help with selecting the selected. So if I have the follow code: select "group", "price", @price, {:prompt => 'All'}and I'm getting that same @price back with the selected string value in @val, how do I make it keep the selected in @val?
nvm got it, thanks for the help