单击按钮时,警报框显示表单数据 [英] Alert box shows form data when clicking button

查看:97
本文介绍了单击按钮时,警报框显示表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在表单底部创建一个按钮,该按钮将创建一个警报框,其中将显示输入的表单数据.表格包括: 名 姓 地址1 地址2 城市 状态 压缩 电话 传真

I am looking to create a button at the bottom of a form that will create an alert box that will show the form data entered. Form includes: First Name Last Name Address 1 Address 2 City State Zip Phone Fax

完成表单后,单击按钮,并弹出一个警告框,显示输入的表单数据.

Once the form is completed, the button is clicked and an alert box pops up showing the form data entered.

有人知道如何在不实际提交或验证表单的情况下完成工作吗?没有要提交的表单数据的数据库,因此没有从中提取信息的数据库.

Does anyone know how to accomplish without the form actually being submitted or validated? There is no database for the form data to be submitted to, so there is no database to pull the information from.

任何帮助将不胜感激.

由于长度原因,我没有包含表单代码,但是我正在为警报框"使用的当前代码如下:

I have not included the form code due to its length, but the current code I am working with for the Alert Box looks like this:

 <script>
 function display_alert()
 {
 alert("");
 }
 </script>

 <body>
 <input type="button" onclick="display_alert()" value="Display alert box">
 </body>

推荐答案

如果我理解正确,则需要这样的东西:

If I get it right you need something like this:

<html>
<head>
<script type="text/javascript">
window.onload = function(){
   document.getElementById('send').onclick = function(e){
       alert(document.getElementById("name").value);
       return false;
   }
}
</script>
</head>
<body>
<form method="post">
<input type="text" name="name" id="name" />
<input type="submit" name="send" id="send" value="send" />
</form>
</body>
</html>

使用数据库从中提取信息并不能真正理解您的意思,但是该示例使用click事件从表单字段中获取数据,并在没有提交的情况下将其显示在警报中.

I don't really get what you mean with a database to pull the information from, but the example uses a click event to get the data from the form field and shows it in an alert without a submit.

这篇关于单击按钮时,警报框显示表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆