2つの行に一連のドロップダウンがあり、2が選択されたときに単純な関数が2つの値を連結し、そのような横に出力:2番目のドロップダウン値が関数の実行を選択し、それがoutput
言う出力を表示したら関数を起動した後にページを更新しないようにする
dropdown1 dropdown2 Output
は、私は何を取得しようとしていること、です。しかし、現時点では、出力が新しいウィンドウに表示されているように見えます。
は、ここで私は今のところ(HTML)持っているものです。
<form>
<select id="test">
<option>Arena/Quantum Barcelona LTBC</option>
<option>Arena/Quantum Spain LTES</option>
</select>
<select id="name" onchange="tryThis()">
<option>Name</option>
<option>Name1</option>
</select>
</form>
はJavaScript:
function tryThis() {
var string, string1 = '';
var e = document.getElementById("test");
string = e.options[e.selectedIndex].text;
var a = document.getElementById("name");
string1 = a.options[a.selectedIndex].text;
document.write(string+'_'+string1);
}
私はそれが必要以上に、これはより困難作っています!
新しい要素を作成するか、既存の要素の内容を設定します。 'document.write'はあなたのページを消去します。そして、私はJSライブラリを使ってそれをもっと簡単にすることをお勧めしたいと思います。 –