gpt4 book ai didi

javascript - 选定的索引未定义

转载 作者:行者123 更新时间:2023-12-02 18:53:10 25 4
gpt4 key购买 nike

我有一个选项字段和onChange,我调用了一个函数,但参数为空

标记

<select name="estado" id="estado" onchange="setCidade(this.SelectedIndex)">
<option name="BR" value="BR">Barueri</option>
<option name="BH" value="BH">Belo Horizonte</option>
<option name="BS" value="BS">Brasilia</option>
<option name="CP" value="CP">Campinas</option>
<option name="CU" value="CU">Cuiaba</option>
<option name="CT" value="CT">Curitiba</option>
<option name="DI" value="DI">Diadema</option>
<option value="DQ">Duque de Caxias</option>
<option value="FL">Florianopolis</option>
<option value="FO">Fortaleza</option>
<option value="GO">Goiania</option>
<option value="GU">Guarulhos</option>
<option value="PA">Porto Alegre</option>
<option value="OS">Osasco</option>
<option value="RE">Recife</option>
<option value="RJ">Rio de Janeiro</option>
<option value="SS">Salvador</option>
<option value="SA">Santo Andre</option>
<option value="SB">São Bernardo do Campo</option>
<option value="SC">São Caetano do Sul</option>
<option value="SP">São Paulo</option>
<option value="VI">Vitória</option>
</select>

Javascript

function setCidade (indiceSelecionado) {
alert(indiceSelecionado);//the alert show "undefined"
indexCidade = indiceSelecionado;
mudarCidade();
}

最佳答案

替换

SelectedIndex

selectedIndex

第一个“s”是小写的。

关于javascript - 选定的索引未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15617456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com