Dojo-如何使用对话框表单提交数据 [英] Dojo - how to submit data using a Dialog form
问题描述
我想提交一些用户以对话框形式输入的值。他单击按钮,提供姓名,名字,电子邮件并提交。
I would like to submit some values that a user enters in a Dialog-form. He clicks on the button, gives his name, first name, email and submit.
当他提交时,我想将这些值存储在数据库中。我有一个应该从用户那里获取这些值的php脚本...但是一旦提交给我的php脚本,我不知道如何发送这些值。
When he submits, I would like to store these values in a DB. I have a php script that is supposed to get these values from the user... but I don't know how to send these values once submitted to my php script.
感谢您的帮助。
--- php脚本------>到目前为止,仅打印,没有数据库存储,但打印不起作用
---php script------> so far just printing, no DB storing but printing is not working
<?php
$name= $_POST["name"];
$firstName= $_POST["firstName"];
$email = $_POST["email"];
print("$name+ $firstName+ $email<br>");
?>
---------- ------------- HTML页面------------------------
-----------------------HTML page------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
<title>
Dojo
</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<link rel="stylesheet" type="text/css" href="../js/dojo/resources/dojo.css">
<link rel="stylesheet" type="text/css" href="../js/dijit/themes/claro/claro.css">
<style type="text/css"> body {margin-left: 10px; margin-top: 10px;} </style> <script type="text/javascript" src="../js/dojo/dojo.js" djconfig="parseOnLoad:true, isDebug: true"></script>
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dojox.validate.regexp");
dojo.addOnLoad(function() {
form = dijit.byId("subscription");
dojo.connect(dijit.byId("button1"), "onClick", form, "show");
});
</script>
`enter code here`</head>
<body class="claro">
<div dojotype="dijit.Dialog" id="subscription" title="subscription form" execute="alert('Transmitted');">
<table>
<tr>
<td>
Name:
</td>
<td>
<input dojotype="dijit.form.TextBox" type="text" name="name" id="name">
</td>
</tr>
<tr>
<td>
FirstName:
</td>
<td>
<input dojotype="dijit.form.TextBox" type="text" name="firstName" id="firstName">
</td>
</tr>
<tr>
<td>
Email :
</td>
<td>
<input type="text" name="mail" id="mail" dojotype="dijit.form.ValidationTextBox"
regexpgen="dojox.validate.regexp.emailAddress">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<button dojotype="dijit.form.Button" type="submit" onclick="return dijit.byId('subscription').isValid();">OK</button>
<button dojotype="dijit.form.Button" type="button" onclick="dijit.byId('subscription').hide();">Annuler</button>
</td>
</tr>
</table>
</div>
<button id="button1" dojotype="dijit.form.Button" type="button">Sign</button>
</body>
</html>
推荐答案
您没有实际的<$ c $对话框中的c>< form> 标记。您需要这样的东西:
You don't have an actual <form>
tag within the dialog. You need something like:
<div dojotype="dijit.Dialog" id="subscription" title="subscription form" execute="alert('Transmitted');">
<form action="PATH_TO_PHP_PAGE" method="POST">
<!--input widgets-->
<!--submit button widgets-->
</form>
</div>
如果要使用具有良好验证功能的dijit表单,则需要 dijit.form.Form
并将其放在表单标签上:
If you want to use the dijit form with the nice validating functionality, you'll need to require dijit.form.Form
and put that on your form tag:
<form dojoType="dijit.form.Form">
这篇关于Dojo-如何使用对话框表单提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!