如何显示这些按钮
我的小提琴中有一个应用程序,用户可以在其中选择他们喜欢的选项和答案。
要使用该应用程序,用户首先从网格中选择一个选项,例如选项“3”,它将在底部显示按钮 A 到 C。
然后,用户在“答案数”文本框中输入数字 2,这意味着用户只能选择从 A 到 C 的 2 个答案。
现在,如果用户选择答案 A 和 B,则这些按钮将变为绿色以显示它们已被选中。
现在,如果用户单击“添加问题”按钮,它将在底部的新行中添加答案。这是我目前遇到的问题。如果您遵循上面的示例,它应该做的是显示所有三个按钮 A 到 C,并选择 A 和 B(绿色),但它只显示三个按钮,但没有选择任何一个按钮。
那么我需要做什么才能在表行中显示选项中的所有按钮,显示从选项中选择的按钮(如果按照上面的示例操作,它应该显示在 A 到 C 行中,并选择了 A 和 B )?
下面是我的代码,它创建新行并显示行中的按钮:
这可以在我的 jsfiddle 中的 javascript 代码底部附近找到,您可以访问 这里
I have an application in my fiddle where the user selects their preferred options and answers.
To use the app the user first selects an option from the grid, lets say option "3" for example, it will displays buttons A to C at the bottom.
The user then lets say type in the number 2 in the Number of Answers Textbox, this means that the user can only select 2 answers from A to C.
Now if the user selects Answers A and B, then those buttons turn green to show they have been selected.
Now if the user clicks on the "Add Question" button, it will add the answer in a new row at the bottom. This is the problem I am getting at the moment. What it is suppose to do if you follow the example above is to show all three buttons A to C with A and B selected (green color) but at it just displays the three buttons with none of them selected.
So what do I need to do to be able to display all the buttons from the option in the table row showing the buttons selected from the option, (if you follow aboves example it should display in the row A to C with A and B selected)?
Below is my code which creates the new row and displays the buttons in the row:
This can be found near the bottom of the javascript code in my jsfiddle which you can access here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以这样编写函数
如果你想清除点击处理程序,请使用这个
you can write the function like this
Use this if you want to clear the click handler