onchange 和 Select 不工作
onchange and Select not working
我正在尝试使用 运行 功能,但不确定如何将其设置为 运行。我尝试单击并为每个 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 = "";
}
您是否围绕函数设置了脚本标签?
您在 Id 末尾漏了一个 s。
document.getElementById("Provider")
不应该这样:
var ProviderValue = document.getElementById("Provider").value;
是这样的:
var ProviderValue = document.getElementById("Providers").value;
我正在尝试使用 运行 功能,但不确定如何将其设置为 运行。我尝试单击并为每个 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 = "";
}
您是否围绕函数设置了脚本标签? 您在 Id 末尾漏了一个 s。
document.getElementById("Provider")
不应该这样:
var ProviderValue = document.getElementById("Provider").value;
是这样的:
var ProviderValue = document.getElementById("Providers").value;