js弹出窗口提交时显示刚刚填写的信息

来源:百度知道 编辑:UC知道 时间:2024/05/12 20:08:02
做了一个个人信息提交的网页,要求在所有信息都提交之后弹出一个对话框,将刚刚填写过的信息都重新在弹出的对话框里显示一遍,请问怎么做,最好详细一些,初学。

你写一个JS函数
在提交按纽那里使用他的 onclick事件关联那个函数

函数体里面
通过document.getElementById('xxx').value 得到你表单里的所有元素的值。。
然后通过
alert()打印出来就是了

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<script>
function submitForm1()
{
var str="";
str+="姓名:"+document.getElementById('txtName').value+"\n";
str+="年龄:"+document.getElementById('txtAge').value+"\n";
str+="性别:"+document.g