Javascript 按钮在组合框菜单中不起作用
我有一个组合菜单。这是没有按钮的工作。我添加了一个按钮,但它不工作。我想在单击按钮时运行。我对JavaScript一无所知。有人能帮我吗?谢谢 asd.phpJavascript 按钮在组合框菜单中不起作用,javascript,php,html,Javascript,Php,Html,我有一个组合菜单。这是没有按钮的工作。我添加了一个按钮,但它不工作。我想在单击按钮时运行。我对JavaScript一无所知。有人能帮我吗?谢谢 asd.php $hello = $_POST['List3']; echo $hello; index.php <script type="text/javascript"> /* Triple Combo Script Credit By Philip M: http://www.codingforums.com/member.php
$hello = $_POST['List3'];
echo $hello;
index.php
<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>
<select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Make a selection</option>
</select>
<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>
/*
三重组合脚本信用
菲利普M:http://www.codingforums.com/member.php?u=186
参观http://javascriptkit.com 对于此脚本和400多个其他脚本
*/
var类别=[];
类别[“惊奇者”]=“服装”、“书籍”]
类别[“服装”]=“男性”、“女性”、“儿童”];
类别[“书籍”]=“传记”、“小说”、“非小说”];
类别[“男士”]=“衬衫”、“领带”、“腰带”、“帽子”];
类别[“女性”]=[“衬衫”、“裙子”、“围巾”、“帽子”];
类别[“儿童”]=“短裤”、“袜子”、“外套”、“睡衣”];
类别[“传记”]=“当代”、“历史”、“其他”];
类别[“小说”]=“科幻小说”、“浪漫小说”、“惊悚片”、“犯罪”];
类别[“非小说”]=[“如何”、“旅行”、“食谱”、“旧教堂”];
变量nLists=3;//集合中的选择列表数
函数fillSelect(currCat,currList){
var step=Number(currList.name.replace(/\D/g,“”);
对于(i=step;i而不是使用javascript“onclick”添加href),添加以下内容:
<a type="button" class="btn btn-warning btn-lg" onclick="getValue()">GONDER</a>
GONDER
你用Javascript而不仅仅是一个GÖNDER
提交此表单有什么原因吗?你的getValue()
所做的似乎就是提交表单?我添加了GÖNDER
并删除了函数getValue()
太好了!它正在工作。谢谢。很棒的东西,作为参考,假设您使用的是Bootstrap或类似的工具,您仍然可以将您的class=“btn btn warning btn lg”
样式放在上。