Submitting all items in a select input, even non-selected items? - ruby-on-rails

I have a form, and the user needs to enter a list of email addresses that will receive a periodic report. I thought a good way to do this would be to have a text input, and buttons to add/remove and clear emails in select box. I used javascript to facilitate the buttons adding/removing and clearing the select box and this works fine. One thing I overlooked is that the select box only returns the selected items, however, in this case I want to return all of them.
Is there a way to return all of the items? One idea I had was to add a hidden input and just add the items in there as well.

Related

Google Sheets - Validation list to default on selection in another cell, but still provide drop-down options

I'm stuck on this one, and after a number of google searches am now wondering if I'm the only person who's ever tried to do this.
I have a google sheet that users are required to fill in. There is a drop-down selection option at the top, specifying the region the user needs the file for.
However, as the user gets down to the lines for the individual items required, some (a small number) may not be for the region selected at the top.
So what I'm trying to do is add the regions to the individual lines. The default for each line should be the region selected at the top, so this should show as pre-selected. But I want the user to be able to still click on a drop-down arrow and select a different region for a line.
Does anyone have any ideas on how to do this? Thank you!
Okay,
I'm unsure of your expected outcome, your request is also not very clear -
What I've done is created a list via Data validation, however, if a user enters data into the adjacent column:
https://docs.google.com/spreadsheets/d/1OsrQCUt-Urf_Gx8_l9CBZkaUlDc311-S-0csa9GAtCQ/edit?usp=sharing
also it's good practice to share an example of your workbook for others to edit and work on.
let me know if this is what you wanted.

Implement a dropdown history in a UITextField or similar component

I have a case where users enter a string, and would like the users to be able to quickly select the previously entered, and validated options they have entered before.
Currently the user enters text via a UITextField, ideally I'd like to keep this, or aesthetically this at least, and have a list of the previously validated inputs drop down below, where tapping any of them would fill the UITextView.
Basically I want a dropbox, which is simply filled with previous inputs, but those inputs are not listed on the main UI, only when the user selects the text view.
Can anyone point me towards how to acomplish this?

Variable-length form submissions

I'd like to create a form_for statement which allows the user to select elements one-by-one from a drop down menu (or an auto-complete field). As the user selects each item, they should be displayed in list format at the top of the screen. When the user has finished selecting elements, the form can be submitted and the list of selected elements is sent to the receiving controller action.
Can someone tell me how to implement this?
Maybe Chosen is what you need.
Take a look at:
http://harvesthq.github.com/chosen/

Rails-Haml, Table display of checkbox selection

I have a table that displays data for the items selected in the checkbox above, like a[], b[], c[]. Initially, when the page is first loaded, the table display is empty. When checkbox selections are made, the tables displays the data for the selection. Then when I untick all checkboxs and press display, the table display should be empty.
In the controller the variable for checkbox selection is thus>
#selected_brands = params[:brands] || session[:brands] || {}
as you may realize, params[], and session[] are values submitted by form in the view. {} -> when no checkboxes are selected.
Again in controller, I have this
#products = Product.find_all_by_brand(#selected_brands.keys)
The problem I have is, when I have unchecked the boxes, following the previous selections I made, the table displays data from previous session, instead of an empty table. What am I not doing?
You run into a HTML issue bugging lots of people: when you uncheck all checkboxes, nothing is sent to the server, and thus no change is recorded, so the last situation is still recorded.
There are many solutions to this (events, javascript, serverside code), so my advise is to broaden your search to generic html how to handle this situation best.
If you don't like Javascript, and have no problem with too many db-actions, remove all selected brands for the product and reapply the chosen ones when you get this result.

List box values on postback

I am using asp.net mvc. I have used two list box in one of my views.
I transfer desired items from left-hand-side list box to right-side list box.
On a button click, i want to get the list box contents from right side list box.
I don;t get in form collection. Can anyone please suggest how can I get it?
thanks,
kapil
The only values in the list box that are selected will appear in the form collection.
When you transfer to the second list box, I would add a hidden field and add the cvalues into there (with some delimiter between). Upon POST you could split the string value of this hidden value to find contents of right hand list box.
Alternatively, just prior to Submit (intercept with JavaScript), set all values in right hand list box to selected.

Resources