これは初めてのことです。私はいくつかのドロップダウンオプションを持つスクリプトを作成しようとしています。最後のドロップダウンから値を取得する必要があります。その値に入力値を掛ける必要があります。ドロップダウンリストからデータを取得するjavascript
価格からデータを取得する方法がわからないため、まだ入力番号が作成されていません。 基本的に価格が表示されている場合は、価格を掛けるための入力番号領域を持つことができるようにこの価格が必要です。
私のフィドルはここにある:http://jsfiddle.net/blaxxzg/sy95ksnL/
var stateObject = {
"Mali format": {
"2/5 cm": ["9,5 €"],
},
"Mali format-tanki": {
"1/3,5 cm": ["12,13 €"],
},
"Veliki format": {
"3/7 cm": ["20,15 €"],
},
"Veliki format-tanki": {
"2/4 cm": ["18,79 €"],
}
}
window.onload = function() {
var stateSel = document.getElementById("stateSel"),
countySel = document.getElementById("countySel"),
citySel = document.getElementById("citySel");
for (var state in stateObject) {
stateSel.options[stateSel.options.length] = new Option(state, state);
}
stateSel.onchange = function() {
countySel.length = 1; // remove all options bar first
citySel.length = 1; // remove all options bar first
if (this.selectedIndex < 1) {
countySel.options[0].text = "Prvo odaberite tip kamena"
citySel.options[0].text = "Prvo odaberite debljinu kamena"
return; // done
}
countySel.options[0].text = "Please select county"
for (var county in stateObject[this.value]) {
countySel.options[countySel.options.length] = new Option(county, county);
}
if (countySel.options.length==2) {
countySel.selectedIndex=1;
countySel.onchange();
}
}
stateSel.onchange(); // reset in case page is reloaded
countySel.onchange = function() {
citySel.length = 1; // remove all options bar first
if (this.selectedIndex < 1) {
citySel.options[0].text = "Please select county first"
return; // done
}
citySel.options[0].text = "Please select city"
var cities = stateObject[stateSel.value][this.value];
for (var i = 0; i < cities.length; i++) {
citySel.options[citySel.options.length] = new Option(cities[i], cities[i]);
}
if (citySel.options.length==2) {
citySel.selectedIndex=1;
citySel.onchange();
}
}
}
私はあなたがここで何を求めているのか分かりません。問題は何ですか? – Seany84
あなたのフィドルのアップデートです。これがあなたが探しているものなら教えてくださいhttp://jsfiddle.net/rrnufjyt/1/ –
これは私が探していたものです。どうもありがとうございました。 @VijendraKulhade –