Javascript 在单选按钮上显示表格选择,然后将单选按钮值传递给表格中的字段,选择添加更多,然后附加到现有表格
第一次海报…请不要打我太坏。我甚至不知道这一切是如何运作的,但事情是这样的。我基本上是在尝试重新创建位于此处的表单: 我现在有产品选择和表格 所需的用户体验:Javascript 在单选按钮上显示表格选择,然后将单选按钮值传递给表格中的字段,选择添加更多,然后附加到现有表格,javascript,Javascript,第一次海报…请不要打我太坏。我甚至不知道这一切是如何运作的,但事情是这样的。我基本上是在尝试重新创建位于此处的表单: 我现在有产品选择和表格 所需的用户体验: 选择产品,产品选择将替换为显示产品选择名称、复选框和数量选择器的表 添加其他产品的选项。如果单击,则显示产品选择,然后重复该过程,将新选择添加到表中 删除以前选择的项目的功能 有人要吗 感谢用户“”的帮助 给你。请注意有关解释的评论 // Get all the product radio buttons and loop them v
感谢用户“”的帮助 给你。请注意有关解释的评论
// Get all the product radio buttons and loop them
var products = document.getElementsByName('product');
for (var i = products.length; i--;) {
// add an event listener to do stuff when one of them is clicked
products[i].addEventListener("click", function() {
// get the value of the clicked button
var cup = this.value;
// put the value in the input box
document.getElementById('yourSelection').value = cup;
// hide the radio buttons and show the table
document.getElementById("cupDesc").style.display = "block";
document.getElementById("cupSelect").style.display = "none";
});
}
请注意,在使用style='display:none'
快乐编码 给你。请注意有关解释的评论
// Get all the product radio buttons and loop them
var products = document.getElementsByName('product');
for (var i = products.length; i--;) {
// add an event listener to do stuff when one of them is clicked
products[i].addEventListener("click", function() {
// get the value of the clicked button
var cup = this.value;
// put the value in the input box
document.getElementById('yourSelection').value = cup;
// hide the radio buttons and show the table
document.getElementById("cupDesc").style.display = "block";
document.getElementById("cupSelect").style.display = "none";
});
}
请注意,在使用style='display:none'
快乐编码 布鲁。这里有可用的代码格式化程序。到目前为止,请包括您的javascript。我尝试了不同的格式化程序,但那是在我将#cupDesc div更改为表之前。我将把我尝试过的东西添加到原始帖子中。眼睛所能看到的格式化程序。我过去常常为别人整理东西,所以有时候。另外,请点击“编辑”按钮添加到问题中,而不是在评论中发布代码。再次道歉,first timer,我对javascript几乎一无所知。我现在正试着做一把小提琴。这里有可用的代码格式化程序。到目前为止,请包括您的javascript。我尝试了不同的格式化程序,但那是在我将#cupDesc div更改为表之前。我将把我尝试过的东西添加到原始帖子中。眼睛所能看到的格式化程序。我过去常常为别人整理东西,所以有时候。另外,请点击“编辑”按钮添加到问题中,而不是在评论中发布代码。再次道歉,first timer,我对javascript几乎一无所知。我现在正在尝试制作小提琴。