让用户填写一个表单,然后点提交的时候,会弹出确认对话框,确认对话框包含用户刚才在表单中填写的数据 5
<script type="text/javascript">
document.getElementById('btn-submit').onclick=function(){
document.getElementById('alert').style.display='block';
//将表单的值显示在对话框上
document.getElementById('label-username').innerHTML=document.getElementById('username').value;
document.getElementById('label-password').innerHTML=document.getElementById('password').value;
//阻止表单提交
return false;
};
//确认
document.getElementById('btn-confirm').onclick=function(){
//提交整个表单
alert("正在提交表单");
//document.getElementById('form').submit();
};
document.getElementById('btn-cancel').onclick=function(){
document.getElementById('alert').style.display='none';
};
</script>
<body>
<form id="form" action="">
<input type="text" id="username" name="username" value="1" />
<input type="text" id="password" name="password" value="2" />
<button id="btn-submit">提交</button>
</form>
<div id="alert" class="alert" style="display: block;">
<label id="label-username"></label>
<label id="label-password"></label>
<button id="btn-confirm">提交</button>
<button id="btn-cancel">取消</button>
</div>
</body>
哪位大神能帮我看下到底哪里出错了! 在线的 ,急啊!! 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
//确认
function a(){
//提交整个表单
document.getElementById('form').submit();
};
function b(){
document.getElementById('alert').style.display='none';
};
function check(){
document.getElementById('alert').style.display='block';
//将表单的值显示在对话框上
document.getElementById('label-username').innerHTML=document.getElementById('username').value;
document.getElementById('label-password').innerHTML=document.getElementById('password').value;
return false;
}
</script>
<body>
<form id="form" action="http://www.baidu.com/" onsubmit="return check();">
<input type="text" id="username" name="username" value="1" />
<input type="text" id="password" name="password" value="2" />
<button id="btn-submit">提交</button>
</form>
<div id="alert" class="alert" style="display: none;">
<label id="label-username"></label>
<label id="label-password"></label>
<button id="btn-confirm" onclick="a();">提交</button>
<button id="btn-cancel" onclick="b();">取消</button>
</div>
</body>
</html>
帮你修改了下。