If it was a lookup-field I would assume you would need two fields.
Up vote 0 down vote favorite share g+ share fb share tw.
I'm creating a form in a Rails 3 app that has a dropdown field. In the dropdown there is an option for "Other", and when you select "Other" a text box appears, and when saved, the text box value is saved instead of the dropdown menu value. I wrote some javascript that accomplishes the above for any select dropdown with the class "has_other".
I'm having trouble figuring out how to reverse this, i.e. When a user is editing the form with existing contents in it, if the field in the database is something other than what is in the select menu, then to display "Other" and the textbox with the custom value in it. I would like to do this via javascript if possible, so I can still have one constant function that works on all select boxes with class = "has_other".
Right now when I view the edit form with data in it, if the value stored in the database is not in the dropdown menu, the first item is selected (as it would be if nothing was selected yet). My question is, is there some way via javascript/jQuery that I could check the "attempted" value of the dropdown so I could use that to manipulate the actual value? Such as, on page load, get the data that the rails object is putting into the form?
Sorry if this is unclear, I'll edit if more info would be useful. Thanks in advance. Javascript jquery forms ruby-on-rails-3 link|improve this question asked Dec 9 '10 at 19:05Sarah194117 100% accept rate.
If it was a lookup-field I would assume you would need two fields. So if that is the case, I would suggest to temporarily add the manually entered element to the dropdown values. That way: the value is visible in the correct place the rest of the interface keeps on working as expected (if they want to change/edit it, they still need to select 'other' again).
Hope this helps.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.