开发者

nest a form input under a checkbox

开发者 https://www.devze.com 2023-03-28 00:37 出处:网络
I have a number of form inputs that I want to submit based on whether it\'s checkbox is selected.开发者_Python百科

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

0

精彩评论

暂无评论...
验证码 换一张
取 消