cpuBrandID = 2 cpuBrandID = 2 非常感谢 Craig " McKirahan" <氖** @ McKirahan.com>在消息中写道 news:fI ******************** @ comcast.com ... Thank you thats what i needI forgot to rewrite the text values to hidden as it was from my web page todisplay my values many thanks Craig"McKirahan" <Ne**@McKirahan.com> wrote in messagenews:fI********************@comcast.com..." ; Craig Keightley <做** @ spam.me>在消息中写道新闻:42 *********************** @ news-text.dial.pipex.com ... "Craig Keightley" <do**@spam.me> wrote in message news:42***********************@news-text.dial.pipex.com...我有以下数组:函数showCPUs()//名称brandID dualCore dualProcessor var cpuItem = [''Pentium 4 HT Northwood'',''2' ',''N'',''N'']; var cpuItem = [''Pentium D 820'',''2'',''Y'',''N'']; var cpuItem = [''Pentium D 830'',''2'',''Y'',''N'']; var cpuItem = [''Pentium D 840'' ,'''',''Y'',''N'']; var cpuItem = [''Xeon'',''2'',''N'',''Y' ']; var cpuItem = [''Xeon'',''2'',''N'',''Y'']; var cpuItem = [''Xeon'', ''''','''',''Y'']; var cpuItem = [''Xeon Dempsey'',''2'',''N'',''Y' ']; var cpuItem = [''Athlon 64 3000'',''1'',''N'', 'N'']; var cpuItem = [''Athlon 64 3200'',''1',''N'',''N'']; var cpuItem = [' 'Athlon 64 3500'',''1',''N'',''N'']; var cpuItem = [''Athlon 64 4000'',''1'',' N'',''N'']; var cpuItem = [''Athlon 64 X2 4200'',''1'',''Y'',''N'']; var cpuItem = [''Athlon 64 X2 4400'',''1',''Y'',''N'']; var cpuItem = [''Athlon 64 X2 4600'', ''1',''Y'',''N'']; var cpuItem = [''Athlon 64 X2 4800'',''1'',''Y'','' N'']; var cpuItem = ['''Opteron 242'',''1'',''N'',''Y'']; var cpuItem = [''Opteron 244'',''1',''N'',''Y'']; var cpuItem = [''Opteron 246'',''1'','N'', ''Y'']; var cpuItem = [''Opteron 252'',''1'',' 'Y'',''Y'']; } < / script> 以及下拉菜单设置的以下隐藏字段 < input name =" cpuBrandID"类型= QUOT;文本" id =" cpuBrandID"> < input name =" dualCoreID"类型= QUOT;文本" id =" dualCoreID"> < input name =" dualProcessorID"类型= QUOT;文本" id =" dualProcessorID"> 如何从 I have the following array: function showCPUs(){ //name brandID dualCore dualProcessor var cpuItem=[''Pentium 4 HT Northwood'',''2'',''N'',''N'']; var cpuItem=[''Pentium D 820'',''2'',''Y'',''N'']; var cpuItem=[''Pentium D 830'',''2'',''Y'',''N'']; var cpuItem=[''Pentium D 840'',''2'',''Y'',''N'']; var cpuItem=[''Xeon'',''2'',''N'',''Y'']; var cpuItem=[''Xeon'',''2'',''N'',''Y'']; var cpuItem=[''Xeon'',''2'',''N'',''Y'']; var cpuItem=[''Xeon Dempsey'',''2'',''N'',''Y'']; var cpuItem=[''Athlon 64 3000'',''1'',''N'',''N'']; var cpuItem=[''Athlon 64 3200'',''1'',''N'',''N'']; var cpuItem=[''Athlon 64 3500'',''1'',''N'',''N'']; var cpuItem=[''Athlon 64 4000'',''1'',''N'',''N'']; var cpuItem=[''Athlon 64 X2 4200'',''1'',''Y'',''N'']; var cpuItem=[''Athlon 64 X2 4400'',''1'',''Y'',''N'']; var cpuItem=[''Athlon 64 X2 4600'',''1'',''Y'',''N'']; var cpuItem=[''Athlon 64 X2 4800'',''1'',''Y'',''N'']; var cpuItem=[''Opteron 242'',''1'',''N'',''Y'']; var cpuItem=[''Opteron 244'',''1'',''N'',''Y'']; var cpuItem=[''Opteron 246'',''1'',''N'',''Y'']; var cpuItem=[''Opteron 252'',''1'',''Y'',''Y'']; } </script> and the following hidden fields that are set by drop down menus <input name="cpuBrandID" type="text" id="cpuBrandID"> <input name="dualCoreID" type="text" id="dualCoreID"> <input name="dualProcessorID" type="text" id="dualProcessorID"> How can I search against the hidden values to generate a list of items我的数组中搜索隐藏值以生成项目列表 from ? 例如 cpuBrandID = 2 dualCoreID = Y dualProcessorID = N 将使用阵列中的以下处理器填充页面: 奔腾D 820 奔腾D 830 奔腾D 840 非常感谢 克雷格 my array? eg cpuBrandID = 2 dualCoreID = Y dualProcessorID = N will populate the page with the following processors from the array: Pentium D 820 Pentium D 830 Pentium D 840 Many Thanks Craig 1)var cpuItem被多次声明。 2)" type = text"不是一个隐藏的领域。 这就是你在找什么?注意自动换行。 < html> < head> < title> cpuItem.htm< / title> < script type = " text / javascript"> var s = 0; var cpuItem = new Array(); cpuItem [s ++] = [''cpuName'',''cpuBrand'' ,''dualCore'',''dualProcessor'']; cpuItem [s ++] = [''Pentium 4 HT Northwood'',''2'',''N'',''N'' ]; cpuItem [s ++] = [''Pentium D 820'',''2'',''Y'',''N'']; cpuItem [s ++] = [' 'Pentium D 830'','''',''Y'',''N'']; cpuItem [s ++] = [''Pentium D 840'',''2'', ''Y'',''N'']; cpuItem [s ++] = [''Xeon'',''2'',''N'',''Y'']; cpuItem [s ++] = [''Xeon'',''2'',''N'',''Y'']; cpuItem [s ++] = [''Xeon'',' '2'','''',''Y'']; cpuItem [s ++] = [''Xeon Dempsey'',''2'','N'',''Y'']; cpuItem [s ++] = [''Athlon 64 3000'',''1'' ,'''',''N'']; cpuItem [s ++] = [''Athlon 64 3200'',''1'',''N'',''N''] ; cpuItem [s ++] = [''Athlon 64 3500'',''1',''N'',''N'']; cpuItem [s ++] = ['' Athlon 64 4000'',''1',''N'',''N'']; cpuItem [s ++] = [''Athlon 64 X2 4200'',''1', ''Y'',''N'']; cpuItem [s ++] = [''Athlon 64 X2 4400'',''1'',''Y'',''N''] ; cpuItem [s ++] = [''Athlon 64 X2 4600'',''1',''Y'',''N'']; cpuItem [s ++] = [' 'Athlon 64 X2 4800'',''1',''Y'',''N'']; cpuItem [s ++] = [''Opteron 242'',''1'', ''N'',''Y'']; cpuItem [s ++] = [''Opteron 244'',''1 ',''N'',''Y'']; cpuItem [s ++] = [''Opteron 246'',''1'',''N'',''Y''] ; cpuItem [s ++] = ['''Opteron 252'',''1'',''Y'',''Y'']; 函数showCPUs(){ var form = document.form1; form.cpuName.value ="" ;; form.dualCore.value = form.dualCore.value.toUpperCase(); form.dualProcessor。 value = form.dualProcessor.value.toUpperCase(); // if(form.cpuBrand.value =="")return; if(" 12" .indexOf (form.cpuBrand.value)< 0){警告(无效的CPU品牌!); 返回; } if(form.dualCore.value =="")return; if(YN.indexOf(form.dualCore.value)< 0){警告(无效的双核心!); 返回; } if(form.dualProcessor.value =="")return; if(" YN" .indexOf(form.dualProcessor.value)< 0){警报(无效双处理器!); 返回; } // var item ="" for(var i = 1; i< cpuItem.length; i ++){ if(form.cpuBrand.value == cpuItem [i] [1]){ if(form.dualCore.value == cpuItem [i] [2 ]){ if(form.dualProcessor.value == cpuItem [i] [3]){ if(item!="")item + =" \\\" ;; item + = cpuItem [i] [0]; } } } } form.cpuName.value = item; } < / script> < / head> < body onload =" document.form1 .cpuBrand.focus()"> < form action =""方法= QUOT;获得" name =" form1"> < b> CPU品牌:< / b> < input type =" text" name =" cpuBrand" size =" 1" MAXLENGTH = QUOT 1 QUOT; onchange =" showCPUs()"> < br> < b>双核(Y / N):< / b> < input type =" text" name =" dualCore" size =" 1" MAXLENGTH = QUOT 1 QUOT; onchange =" showCPUs()"> < br> < b>双处理器(Y / N):< / b> < input type =" text" name =" dualProcessor" size =" 1" MAXLENGTH = QUOT 1 QUOT; onchange =" showCPUs()"> < br>< br> < b> CPU名称:< / b> < br>< textarea name =" cpuName" COLS = QUOT; 30英寸; rows =" 10" readonly style =" background-color:lightyellow">< / textarea> < br> < br>< input type =" ;重置" value =" Clear" onclick =" document.form1.cpuBrand.focus()"> < / form> < / body> < ; / html> 1) "var cpuItem" is declared multiple times. 2) "type=text" is not a hidden field. Is this what you''re looking for? Watch for word-wrap. <html> <head> <title>cpuItem.htm</title> <script type="text/javascript"> var s = 0; var cpuItem = new Array(); cpuItem[s++] = [''cpuName'',''cpuBrand'',''dualCore'',''dualProcessor'']; cpuItem[s++] = [''Pentium 4 HT Northwood'',''2'',''N'',''N'']; cpuItem[s++] = [''Pentium D 820'',''2'',''Y'',''N'']; cpuItem[s++] = [''Pentium D 830'',''2'',''Y'',''N'']; cpuItem[s++] = [''Pentium D 840'',''2'',''Y'',''N'']; cpuItem[s++] = [''Xeon'',''2'',''N'',''Y'']; cpuItem[s++] = [''Xeon'',''2'',''N'',''Y'']; cpuItem[s++] = [''Xeon'',''2'',''N'',''Y'']; cpuItem[s++] = [''Xeon Dempsey'',''2'',''N'',''Y'']; cpuItem[s++] = [''Athlon 64 3000'',''1'',''N'',''N'']; cpuItem[s++] = [''Athlon 64 3200'',''1'',''N'',''N'']; cpuItem[s++] = [''Athlon 64 3500'',''1'',''N'',''N'']; cpuItem[s++] = [''Athlon 64 4000'',''1'',''N'',''N'']; cpuItem[s++] = [''Athlon 64 X2 4200'',''1'',''Y'',''N'']; cpuItem[s++] = [''Athlon 64 X2 4400'',''1'',''Y'',''N'']; cpuItem[s++] = [''Athlon 64 X2 4600'',''1'',''Y'',''N'']; cpuItem[s++] = [''Athlon 64 X2 4800'',''1'',''Y'',''N'']; cpuItem[s++] = [''Opteron 242'',''1'',''N'',''Y'']; cpuItem[s++] = [''Opteron 244'',''1'',''N'',''Y'']; cpuItem[s++] = [''Opteron 246'',''1'',''N'',''Y'']; cpuItem[s++] = [''Opteron 252'',''1'',''Y'',''Y'']; function showCPUs() { var form = document.form1; form.cpuName.value = ""; form.dualCore.value = form.dualCore.value.toUpperCase(); form.dualProcessor.value = form.dualProcessor.value.toUpperCase(); // if (form.cpuBrand.value == "") return; if ("12".indexOf(form.cpuBrand.value) < 0) { alert("Invalid CPU Brand!"); return; } if (form.dualCore.value == "") return; if ("YN".indexOf(form.dualCore.value) < 0) { alert("Invalid Dual Core!"); return; } if (form.dualProcessor.value == "") return; if ("YN".indexOf(form.dualProcessor.value) < 0) { alert("Invalid Dual Processor!"); return; } // var item = "" for (var i=1; i<cpuItem.length; i++) { if (form.cpuBrand.value == cpuItem[i][1]) { if (form.dualCore.value == cpuItem[i][2]) { if (form.dualProcessor.value == cpuItem[i][3]) { if (item != "") item += "\n"; item += cpuItem[i][0]; } } } } form.cpuName.value = item; } </script> </head> <body onload="document.form1.cpuBrand.focus()"> <form action="" method="get" name="form1"> <b> CPU Brand : </b> <input type="text" name="cpuBrand" size="1" maxlength="1" onchange="showCPUs()"> <br> <b> Dual Core (Y/N) : </b> <input type="text" name="dualCore" size="1" maxlength="1" onchange="showCPUs()"> <br> <b> Dual Processor (Y/N) : </b> <input type="text" name="dualProcessor" size="1" maxlength="1" onchange="showCPUs()"> <br><br> <b> CPU Name(s) :</b> <br><textarea name="cpuName" cols="30" rows="10" readonly style="background-color:lightyellow"></textarea> <br> <br><input type="reset" value="Clear" onclick="document.form1.cpuBrand.focus()"> </form> </body> </html> 这篇关于更新:填写搜索结果所需的帮助 - 数组搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 01:18