我得到了 7 select,我需要讀取它們的值以便稍后使用它,但是我只能讀取第一個選擇的值,如果我嘗試讀取第二個或多個,它會崩潰。我需要能夠識別哪個selects'值""與讀取它不同,但如果該值等于"",則忽略它。這是我的腳本:$(document).ready(function() { $("#MENU").change(function() { $(this).find("option:selected").each(function() { var optionValue = $(this).attr("value"); if (optionValue) { $(".box").not("." + optionValue).hide(); $("." + optionValue).show(); } else { $(".box").hide(); } }); }).change();});function myFuction() { //Getting Value //var selValue = document.getElementById("singleSelectDD").value; var selObj = document.getElementById("MENU"); var selValue = selObj.options[selObj.selectedIndex].value; //Setting Value document.getElementById("valorsel").value = selValue;}function ELEMENTO() { //Getting Value //var selValue = document.getElementById("singleSelectDD").value; var modifica1 = document.getElementById("AREA"); var modifica2 = document.getElementById("BANCO"); var modifica3 = document.getElementById("USOCFDI"); var modifica4 = document.getElementById("DEPARTAMENTO"); var modifica5 = document.getElementById("EMPRESA"); var modifica6 = document.getElementById("GIRO"); var modifica7 = document.getElementById("NEGOCIO"); var modval1 = modifica1.options[modifica1.selectedIndex].value; var modval2 = modifica2.option[modifica2.selectedIndex].value; var modval3 = modifica3.option[modifica3.selectedIndex].value; var modval4 = modifica4.option[modifica4.selectedIndex].value; var modval5 = modifica5.option[modifica5.selectedIndex].value; var modval6 = modifica6.option[modifica6.selectedIndex].value; var modval7 = modifica7.option[modifica7.selectedIndex].value;}});
同時從多個選擇中獲取和存儲值
慕田峪4524236
2021-09-30 15:22:45