申し訳ありませんが、私は通常、このようなことを自分でやっていますが、私は制御できません。私は通常、Webスクリプト言語で働いていません(私はC++を学んでいますが、私は過去に多くのhtml経験をしていましたので、私の上司が私を仕事に就かせてくれました)しかし、私はいくつかのコードを3つのコンボボックスの入力は、htmlのjavascriptを使用します。小さなプロジェクトを完成させてaspxのページに入れるまでは、htmlと同じ方法でjsを処理しませんでしたが、私はaspxを認識しませんでした。これは小さいと思われる問題ですが、go()関数はもはや正しく動作しません。私はgo()関数にアラートボックスを入れてテストしました。アラートボックスがボタンのクリックで表示されたため、go関数がまだ呼び出されているようですが、その値をジャンプすることはできません。 3番目のコンボボックス。誰かがこのタスクを完了する他の方法についてのaspxまたは任意の提案のURLを変更するために動作する迅速な修正を知っていますか?どんな助力も大変ありがとうございます。ありがとうございました。JSがaspxからhtmlに変更されました
<script language="JavaScript" type="text/javascript">
// first combo box
data_1 = new Option("Acura", "$");
// second combo box
data_1_1 = new Option("MDX", "-");
// third combo box
data_1_1_1 = new Option("2007", "http://www.DawnEnterprises.co/2007-Acura-MDX-Accessories.aspx");
displaywhenempty=""
valuewhenempty=-1
displaywhennotempty="-select-"
valuewhennotempty=0
function change(currentbox) {
numb = currentbox.id.split("_");
currentbox = numb[1];
i=parseInt(currentbox)+1
while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
son = document.getElementById("combo_"+i);
for (m=son.options.length-1;m>0;m--) son.options[m]=null;
son.options[0]=new Option(displaywhenempty,valuewhenempty)
i=i+1
}
stringa='data'
i=0
while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
(document.getElementById("combo_"+i)!=null)) {
eval("stringa=stringa+'_'+document.getElementById(\"combo_"+i+"\").selectedIndex")
if (i==currentbox) break;
i=i+1
}
following=parseInt(currentbox)+1
if ((eval("typeof(document.getElementById(\"combo_"+following+"\"))!='undefined'")) &&
(document.getElementById("combo_"+following)!=null)) {
son = document.getElementById("combo_"+following);
stringa=stringa+"_"
i=0
while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {
if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
else
eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
else
eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
i=i+1
}
//son.focus()
i=1
combostatus=''
cstatus=stringa.split("_")
while (cstatus[i]!=null) {
combostatus=combostatus+cstatus[i]
i=i+1
}
return combostatus;
}
}
function go(the_value) {
location =
document.MMYSearch.combo2.
options[document.MMYSearch.combo2.selectedIndex].value
}
</script>
<form id="MMYSearch" action="../../../js/MMYSearch.js" name="MMYSearch">
<h4>Vehicle <span class="selection">Selection</span></h4>
<p>Select the Make of your vehicle:</p>
<select name="combo0" id="combo_0" onchange="change(this);" style="width:230px;">
<option value="value1">-select-</option>
<option value="value2">Acura</option>
</select>
<p>Select the Model of your vehicle:</p>
<select name="combo2" id="combo_1" onchange="change(this);" style="width:230px;">
</select>
<p>Select the Year of your vehicle:</p>
<select name="combo2" id="combo_2" onchange="change(this);" style="width:230px;">
</select>
<div>
<input type="button" name="Select" value="Select" onclick="go()" />
</div>
</form>
あなたの 'go()'は何をすべきでしょうか?今のところ、 'location =" something "は私にはあまり意味がありません: –
あなたの奇妙なコードがevalとstrang type checkでいっぱいですが、それらを削除できますか? –
そのevalはまったく必要ありません。 ifをtypeof(document.getElementById( "combo _" + i))!= "undefined"に置き換えることができます。 – jrummell