[英]Show table on radio button select, then pass radio button value to field in table, option to add more, then append to existing table
第一次发布海报......请不要打扰我。 我甚至不确定这一切是如何运作的,但是这里有。 我基本上试图重新创建位于此处的表单:http: //yeticustomshop.com/get-quote我有产品选择显示,表格现在显示。
需要的用户体验:
任何接受者?
// 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";
});
}
感谢用户“ 我曾经摔过一只熊 ”的帮助!
干得好。 请注意解释的注释。
// 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'
单击单选按钮之前,应隐藏选择表
快乐的编码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.