Javascript 如何从下拉列表中获取值

Javascript 如何从下拉列表中获取值,javascript,dom,contact-form-7,Javascript,Dom,Contact Form 7,让我看看 选择您的收件人,并请指定您的收件人 若我选择除SIS Bona Vista之外,那个么旁边的列是隐藏的。但这不是工作 <div class="edgt-grid-col-6"><label>Choose your recipient </label> [select* select-a-schools id:SelectSchools "SIS Bona Vista" "SIS Kelapa Gading" "

让我看看

选择您的收件人,并请指定您的收件人

若我选择除SIS Bona Vista之外,那个么旁边的列是隐藏的。但这不是工作

    <div class="edgt-grid-col-6"><label>Choose your recipient </label>
                [select* select-a-schools id:SelectSchools "SIS Bona Vista" "SIS Kelapa Gading" "SIS Pantai Indah Kapuk" "SIS Cilegon" "SIS Semarang" "SIS Palembang" "SIS Medan"]
        </div>

<div id="SelectBv" class="edgt-grid-col-6">
<label> Please Specify Your Reicipient </label>
[select* select-a-bv include_blank "Techer" "Student" "General"] 
</div>
选择您的收件人
[select*select-a-schools id:SelectSchools“SIS Bona Vista”“SIS Kelapa Gading”“SIS Pantai Indah Kapuk”“SIS Cilegon”“SIS Semarang”“SIS Palembang”“SIS Medan”]
请指定您的委托人
[选择*select-a-bv包括_blank“技术人员”“学生”“常规”]
这是JavaScipt代码:

<script language="javascript" type="text/javascript">
// Show the Text field by default
document.getElementById('SelectBv').style.display = 'true';
document.getElementById('SelectSchools').addEventListener('change', displayTextField);
function displayTextField() {
  // Get the value of the currently selected dropdown. 'select-a-schools' is the name of the dropdown you specify in the form builder
  var cmbSchool = document.querySelector('input[name="select-a-schools"]:select').value;
  if (cmbSchool == 'SIS Bona Vista') {
    document.getElementById('SelectBv').style.display = 'true';
  } else {
    document.getElementById('SelectBv').style.display = 'none';
  }
}
</script>

//默认情况下显示文本字段
document.getElementById('SelectBv').style.display='true';
document.getElementById('SelectSchools')。addEventListener('change',displayTextField);
函数displayTextField(){
//获取当前选定下拉列表的值。“select-a-schools”是您在表单生成器中指定的下拉列表的名称
var cmbSchool=document.querySelector('input[name=“select-a-schools”]:select')。值;
如果(cmbSchool=='SIS Bona Vista'){
document.getElementById('SelectBv').style.display='true';
}否则{
document.getElementById('SelectBv').style.display='none';
}
}

您的问题很难理解,但您可以使用
document.getElementsByClassName(“styledSelect”)[0].innerHTML
获取下拉框的选定值,因此它看起来如下所示

document.getElementById('SelectBv').style.display = 'true';
document.getElementById('SelectSchools').addEventListener('change', displayTextField);
function displayTextField() {
  var cmbSchool = document.getElementsByClassName("styledSelect")[0].innerHTML;
  if (cmbSchool == "SIS Bona Vista") {
    document.getElementById('SelectBv').style.display = 'true';
  } else {
    document.getElementById('SelectBv').style.display = 'none';
  }
}  

清楚地解释问题我不认为select有输入标记,只有select标记
style.display='true'-请不要,我没有改变他的任何代码,只是增加了一行。除了他的问题,我没有试图改善其他任何事情。我相信我注意到了这一点。