下拉选项,然后弹出警报 [英] dropdown options and then alert pop up
本文介绍了下拉选项,然后弹出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建任何种类的下拉列表并显示警报以显示所选值
JavaScript和链接部分到文件
creating any kind of drop-down list and alert show the selected value
The JavaScript and linking part to the file
推荐答案
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
<pre lang="cs">var myform = document.getElementById("someform")
for (var i = 0; i < myform.elements.length; i++)
if (myform.elements[i].type == "select-one" || myform.elements[i].type == "select-multiple") {
myform.elements[i].className = "selectclass"
}
}
<title>Dropdown Alert</title>
</head>
<body>
<form action="HTMLPage.htm">
<h1>Choose one option at a time</h1>
<select id="sample" onchange="alertselected(this)">
<option value="val0">GMAIL</option>
<option value="val1">TWITTER</option>
<option value="val2">FACEBOOK</option>
<option value="val3">INSTAGRAM</option>
<option value="val4">FLIXTER</option>
</select>
<input type="button" onclick="alertselected(document.getElementById())" value="alert" />
</form>
</body>
</html></pre>
,但不是所需的紧凑型解决方案.
想通了,但是使用了此功能.
but not the desired compact solution.
figured out though,, used this function.
这篇关于下拉选项,然后弹出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文