<table id="selectsupp">
<tr>
<td>
<select id="category">
<option value="display" readonly="true">-Shop By Category-</option>
<option value="all">All</option>
<option value="preworkout">Pre Workout</option>
<option value="protein">Protein</option>
<option value="mass">Mass Gainer</option>
<option value="bcaa">BCAA</option>
</select>
</td>
</tr>
<tr>
<td>
<select id="company">
<option value="display" readonly="true">-Shop By Company-</option>
<option value="all">All</option>
<option value="on">Optimum Nutrition</option>
<option value="mts">MTS</option>
<option value="mutant">Mutant Nutrition</option>
<option value="allmax">All Max</option>
</select>
</td>
<td>
<input type="submit" id="submit" name="search" value="Search" onclick="find()"/>
</td>
</tr>
</table>
<script>
function find(){
var category = document.getElementById('category');
var valueOfCategory = category.options[category.selectedIndex].value;
var company = document.getElementById('company');
var valueOfCompany = company.options[company.selectedIndex].value;
if (valueOfCategory === "all" && valueOfCompany === "all") {
alert "hello";
document.getElementsByTagName("select")[0].style.visibility = "hidden";
document.getElementsByTagName("select")[1].style.visibility = "hidden";
//display all suggested items
}
Hello编程员:)我在设置标签的可见性方面遇到了一些麻烦。当我提交我试图摆脱2选择选项和按钮也因为某种原因它设置.style.visibility =&#34;隐藏&#34;不管用。有什么建议吗?
答案 0 :(得分:3)
有两个问题
alert "hello";
应该是
alert("hello");
在功能结束时缺少}
。而且我也没有看到script
标签的关闭。
答案 1 :(得分:0)
好吧,如果您在查看浏览器的调试控制台时感到困扰,那么您已经看到在那里记录了语法错误:
alert "hello";
应该是
alert("hello");
只要网页上的某些内容无效,调试控制台就应该是您的 FIRST 停止。