nest a form input under a checkbox
I have a number of form inputs that I want to submit based on whether it's checkbox is selected.开发者_Python百科
So for example, I want to have
checkbox - label - dropdown selection input
checkbox - label - text field input
checkbox - label - default value
where the dropdown selection and other input fields are only submitted to the form if their checkbox is selected. If it's not checked then it would simply treat the field as blank.
Hope this was fairly clear, Thanks!
There is no way for rails to do it (its server side code so once the page is served its done). So you need to use Javascript.
Here is an example of what you are looking to do on my jsfiddle
精彩评论