当前位置: 代码迷 >> JavaScript >> javascript基础操作(禁用旋钮)
  详细解决方案

javascript基础操作(禁用旋钮)

热度:118   发布时间:2012-08-29 08:40:14.0
javascript基础操作(禁用按钮)

<html>
<head>
<script type="text/javascript">
function disp_prompt()
? {
? var name=prompt("请输入您的名字","Bill Gates")
? if (name!=null && name!="")
??? {
????? if(name=="jackssy"){
????? document.write("wondeful !"+name+" 哈哈");
????? exit(0);
???? }
??? document.write("你好!" + name + " 今天过得怎么样?")
??? }
?
? }
function disp_confirm()
?{
?? var cof = confirm("you? press a confirm");
? if(cof ==true){
???? alert("you press a ok");
? }
? else {
?alert("no");
}
?}

function disp_prompt2()
{
var name1 =prompt("nihao","jackssy")
if(name1!=null &&name1!="")
{
?alert(name1+" hehe");
?document.write(name1+" hehe");
}
}
</script>
</head>
<body>

<input type="button" onclick="disp_prompt()" value="显示提示框" />
<input type="button" onclick="disp_confirm()" value="show confirm">
<input type="button" onclick="disp_prompt2()" value="haha">

</body>
</html>

?

<html>
<head>
<script type="text/javascript">
onerror=handleErr
var txt=""

function handleErr(msg,url,l)
{
txt="本页中存在错误。\n\n"
txt+="错误:" + msg + "\n"
txt+="URL: " + url + "\n"
txt+="行:" + l + "\n\n"
txt+="点击“确定”继续。\n\n"
alert(txt)
return true
}

function message()
{
adddlert("Welcome guest!")
}
</script>
</head>

<body>
<input type="button" value="查看消息" onclick="message()" />
</body>

</html>

?

?

<html>
<head>
<script type="text/javascript">
function alertId()
{
var txt="Id: " + document.getElementById("myButton").id
txt=txt + ", type: " + document.getElementById("myButton").type
alert(txt)
document.getElementById("myButton").disabled=true
}
</script>
</head>

<body>
<form>
<button id="myButton" onClick="alertId()">请点击我!</button>
</form>
</body>

</html>

?

?

?

?

<html>
<head>
<script type="text/javascript">
function disable()
? {
? document.getElementById("mySelect").disabled=true
? }
function enable()
? {
? document.getElementById("mySelect").disabled=false
? }
</script>
</head>
<body>

<form>
<select id="mySelect">
? <option>苹果</option>
? <option>桃子</option>
? <option>香蕉</option>
? <option>桔子</option>
</select>
<br /><br />
<input type="button" onclick="disable()" value="禁用列表">
<input type="button" onclick="enable()" value="启用列表">
</form>

</body>
</html>

  相关解决方案