0
function ff_CselRegion_action(element, action)
{
country = ff_getElementByName('CselCountry');
state = ff_getElementByName('CselState');
var America_NorthArray = new Array('Antigua and Barbuda', 'Canada', 'Greenland', 'USA', 'Mexico');
if (element.value == 'none') {
// drop countries
while (country.options.length > 0)
country.options[country.options.length-1] = null;
} else {
// get the matching array
var selectedArray = eval(element.value+'Array');
// drop supernumerous option
while (selectedArray.length < country.options.length-1)
country.options[country.options.length-1] = null;
// add the new options
country.options[0] = new Option('Select Country', 'none', true, true);
for (var i = 0; i < selectedArray.length; i++)
country.options[i+1] =
new Option(selectedArray[i], selectedArray[i]);
} // if
// drop states
while (state.options.length > 0)
state.options[state.options.length-1] = null;
} // ff_CselRegion_action
function ff_CselCountry_action(element, action)
{
state = ff_getElementByName('CselState');
var stateArrayAntigua and Barbuda = new Array(
'Saint George', 'Saint John', 'Saint Mary', 'Saint Paul'
var selectedArray = eval('stateArray'+element.value);
if (selectedArray == null) {
while (state.options.length > 0)
state.options[(state.options.length - 1)] = null;
} else {
// drop supernumerous option
while (selectedArray.length < state.options.length-1)
state.options[state.options.length-1] = null;
// add the new options
state.options[0] = new Option('Select State', 'none', true, true);
for (var i=0; i < selectedArray.length; i++)
state.options[i+1] = new Option(selectedArray[i], selectedArray[i]);
} // if
} //ff_CselCountry_action
私はそれがスペースを持っており、(var America_NorthArray
)で「アンティグア・バーブーダ」を「見る」ことができないので(var stateArrayAntigua and Barbuda
)のための解決策を見つけようとしています。私がプログラミングでは新しいので、あなたの答えはできるだけシンプルになるように感謝します。事前にありがとうアンティグアとバミューダ、私はそれを "見る"ことができない、私はスペースのためだと思いますか?
P.S.私はインターネットで検索しましたが、私はそれを解決することはできませんでした。
ありがとうございました。私はそれを前に考えてみましたが、問題は両方ともAntigua_and_Barbudaでなければなりません。これが起こると、ドロップダウンリストにはそのように表示され、私はこれを望まない。アンティグアとバミューダ(アンダースコアなし)として表示したい – GalanopD
@ギャラノップ「どちらもvarはアンティグアとバブーダでなければならない」とはどういう意味ですか?両方ですか? 2つの変数が必要な場合は、2つ(名前は異なる)を作成しますが、空白を含む変数を持つことはできません。 'window [" stateArrayAntigua and Barbuda "] = ...'や 'var myNewObject = {" stateArrayAntigua and Barbuda ":some value}'のような名前のプロパティを持つオブジェクトを作成することができます。 – YakovL
あなたは閉じ括弧にぴったりです。コピー/貼り付けの間違いです。上記のコードはうまくいきます。単なる名前の国になったときにテストされています。しかし、その国にはもっと多くのものがあります...私はそれをうまくいかない方法を知りません! – GalanopD