我试图运行该功能,但我不知道如何让它运行。我试着点击并为每个select.all创建单独的函数。我希望函数做的是当我选择将段落的值更改为下面的选项时。请帮忙。
<select id="Providers" onchange="ProviderChanger()">
<option value="Empty" id="Empty" name="Empty">Please Select Provider</option>
<option value="Du1" id="Du1" name="Du1">Du 052</option>
<option value="Du2" id="Du2" name="Du2">Du 055</option>
<option value="Etisilat1" name="Etisilat1" id="Etisilat1">Etisilat 050</option>
<option value="Etisilat2" name="Etisilat2" id="Etisilat2">Etisilat 056</option>
<option value="Office" name="Office" id="Office">House/Office 04</option>
</select>
function ProviderChanger()
{
var ProviderValue = document.getElementById("Provider").value;
alert(ProviderValue);
if (ProviderValue == "Du1")
document.getElementById("Provider").innerHTML = "+971-55";
else if (ProviderValue == "Du2")
document.getElementById("Provider").innerHTML = "+971-52";
else if (ProviderValue == "Etisilat1")
document.getElementById("Provider").innerHTML = "+971-50";
else if (ProviderValue == "Etisilat2")
document.getElementById("Provider").innerHTML = "+971-56";
else if (ProviderValue == "Office")
document.getElementById("Provider").innerHTML = "+971-04";
else
document.getElementById("Provider").innerHTML = "";
}
答案 0 :(得分:1)
不应该这样:
var ProviderValue = document.getElementById("Providers").value;
是这样的:
// str is a global variable, so it is safe to reference it with &
string str = str1 + '\0' + str2 + '\0' + str3 + '\0' + str4;
func_that_needs_null_separated_str(&str[0]);
答案 1 :(得分:0)
您是否在功能周围设置了脚本标签? 你错过了你的Id的结尾。
的document.getElementById( “提供者”)