首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按钮在组合框菜单中不起作用

按钮在组合框菜单中不起作用
EN

Stack Overflow用户
提问于 2015-01-07 18:00:05
回答 1查看 44关注 0票数 0

我有一个组合框菜单。它是无按钮工作。我添加了一个按钮,但它不起作用。我想在点击按钮时运行。我对JavaScript一无所知。有人能帮我吗?谢谢。

asd.php

代码语言:javascript
复制
$hello = $_POST['List3'];
echo $hello;

index.php

代码语言:javascript
复制
<script type="text/javascript">

/*
Triple Combo Script Credit
By Philip M: http://www.codingforums.com/member.php?u=186
Visit http://javascriptkit.com for this and over 400+ other scripts
*/

var categories = [];
categories["startList"] = ["Wearing Apparel","Books"]
categories["Wearing Apparel"] = ["Men","Women","Children"];
categories["Books"] = ["Biography","Fiction","Nonfiction"];
categories["Men"] = ["Shirts","Ties","Belts","Hats"];
categories["Women"] = ["Blouses","Skirts","Scarves", "Hats"];
categories["Children"] = ["Shorts", "Socks", "Coats", "Nightwear"];
categories["Biography"] = ["Contemporay","Historical","Other"];
categories["Fiction"] = ["Science Fiction","Romance", "Thrillers", "Crime"];
categories["Nonfiction"] = ["How-To","Travel","Cookbooks", "Old Churches"];

var nLists = 3; // number of select lists in the set

function fillSelect(currCat,currList){
var step = Number(currList.name.replace(/\D/g,""));
for (i=step; i<nLists+1; i++) {
document.forms['tripleplay']['List'+i].length = 1;
document.forms['tripleplay']['List'+i].selectedIndex = 0;
}
var nCat = categories[currCat];
for (each in nCat) {
var nOption = document.createElement('option'); 
var nData = document.createTextNode(nCat[each]); 
nOption.setAttribute('value',nCat[each]); 
nOption.appendChild(nData); 
currList.appendChild(nOption); 
} 
}

function getValue() {
    document.forms["tripleplay"].submit();
}

function init() {
fillSelect('startList',document.forms['tripleplay']['List1'])
}

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);    

</script> 









<form name="tripleplay" action="asd.php" method="POST">
<select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
<option selected>Make a selection</option>
</select>
&nbsp;
<select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Make a selection</option>
</select>
&nbsp;
<select name='List3' onchange="getValue(this.value, this.form['List2'].value, 
this.form['List1'].value)">
<option selected >Make a selection</option>
</select>

      <center><a type="button" href="javascript: getValue()" class="btn btn-warning btn-lg">GÖNDER</a></center>


</form>
EN

回答 1

Stack Overflow用户

发布于 2015-01-07 18:46:29

使用"onclick“代替使用javascript添加href,添加以下内容:

代码语言:javascript
复制
<a type="button" class="btn btn-warning btn-lg" onclick="getValue()">GONDER</a>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27816803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档