[英]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.