onClick与下拉菜单在Chrome中不起作用

时间:2021-11-13 19:32:17

I have a form that uses a drop down menu to show hidden parts of the form for the users. This is to keep the form looking simple at first glance. Here is the webaddress: http://www.azerventures.com/reservations2.php

我有一个表单,使用下拉菜单为用户显示表单的隐藏部分。这是为了使表格初看起来简单。这是webaddress:http://www.azerventures.com/reservations2.php

I have tested this in IE and FF and it works exactly as expected but it wont work in Chrome. I have seen many articles on similar issues but I can't seem to get the fixes to work on my site. I just don't know javascript well enough. Here is my code:

我已经在IE和FF中对此进行了测试,它的工作原理与预期完全相同,但它无法在Chrome中运行。我见过很多关于类似问题的文章,但我似乎无法在我的网站上修复工作。我只是不太了解javascript。这是我的代码:

<script type="text/javascript" language="javascript">
function Display(which) {
  tn=document.getElementById("Tent");
  fs=document.getElementById("Fishing");
  wl=document.getElementById("Wall");
  tr=document.getElementById("Trip");
  if (which=='Tent2') tn.style.display="block";
    else tn.style.display="none";
  if (which=='Fishing2') fs.style.display="block";
    else fs.style.display="none";
  if (which=='Wall2') wl.style.display="block";
    else wl.style.display="none";
  if (which=='Trip2') tr.style.display="block";
    else tr.style.display="none";
}
</script>


<select style="float: left; margin-bottom: 20px;" name="item1" 
onchange="if(this.options[this.selectedIndex].onclick && document.all) 
this.options[this.selectedIndex].onclick()">
<option selected>Select An Option</option>
<option name="tent2" onClick="Display('Tent2');">Reserve a Tent</option>
<option name="Fishing2" onClick="Display('Fishing2');">Reserve a Fishing Set</option>
<option name="Wall2" onClick="Display('Wall2');">Rent out the Climbing Wall</option>
<option name="Trip2" onClick="Display('Trip2');">Book a Climbing Trip</option>
</select>

<div name="Tent" id="Tent" style="display: none; margin-bottom: 20px;"></div>

The form is inside form brackets and there are other divs, I didn't include it all for ease of reading. Thanks so much for your help!

表单位于表单括号内,还有其他div,我没有将其全部包含在内以方便阅读。非常感谢你的帮助!

1 个解决方案

#1


0  

following line of code is automatically escaped and rendered like this

下面的代码行会自动转义并像这样呈现

onchange="if(this.options[this.selectedIndex].onclick &amp;&amp; document.all) this.options[this.selectedIndex].onclick()"

#1


0  

following line of code is automatically escaped and rendered like this

下面的代码行会自动转义并像这样呈现

onchange="if(this.options[this.selectedIndex].onclick &amp;&amp; document.all) this.options[this.selectedIndex].onclick()"