[英]Show table on radio button select, then pass radio button value to field in table, option to add more, then append to existing table
First-time poster...please don't beat me up too bad. 第一次发布海报......请不要打扰我。 I'm not even sure how all of this works, but here goes.
我甚至不确定这一切是如何运作的,但是这里有。 I'm basically trying to recreate the form located here: http://yeticustomshop.com/get-quote I have the product selection showing and the table showing as of right now.
我基本上试图重新创建位于此处的表单:http: //yeticustomshop.com/get-quote我有产品选择显示,表格现在显示。
Needed user experience: 需要的用户体验:
Any takers? 任何接受者?
// 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";
});
}
Thanks to user " I wrestled a bear once " for the help! 感谢用户“ 我曾经摔过一只熊 ”的帮助!
Here you go. 干得好。 Please pay attention to the comments for the explanation.
请注意解释的注释。
// 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";
});
}
Note that you should hide the selection table until the radio button is clicked with style='display:none'
请注意,在使用
style='display:none'
单击单选按钮之前,应隐藏选择表
Happy coding! 快乐的编码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.