表单提交(Basic Form Submit)

简介: In this small tutorial, we'll try to build an Ext form that will submit in the tradional way, like all regular html forms Introduction As a pro...

In this small tutorial, we'll try to build an Ext form that will submit in the tradional way, like all regular html forms

img_d05563fa34a9855c9c94ef41225fc3ec.png Introduction

As a programmer, you may know PHP (or ASP, or any other server-side language) and the tradional way of working with user-interfaces. You build forms in your server-side language, and output them in plain-text html to the end-user. You may use a templating engine, but in the end, you're sending nicely formatted html to the end-user.

With Ext, it's really easy to build nice-looking forms and interfaces, so you'd like to use that. But you also have a lot of code that already works, which you'd rather keep than converting all of it to handle JSON-formatted data etc.

At least, that was and is my current situation.

img_d05563fa34a9855c9c94ef41225fc3ec.png Getting Started: the HTML page

You've most probably already read how to include all required Ext-code in your page, but let me repeat that for you: (place this in the head-section of your html doc)

<title>A tradional form</title>

<script></script>
<script></script>
 

<script></script>  
 
 

<link>

Next to that, your page certainly needs a place where we'll render the form. (put this in the body of your page)

<div></div>

That's it, for you html code. You can put this in a regular html file (e.g. form.html), or you can output it via a server-side script. Doesn't matter.

img_d05563fa34a9855c9c94ef41225fc3ec.png The Javascript code

Next, we'll build the Javascript code. Best practice seems to be to put this in a separate file. I've called it "mytestscript.js" (see html above). Doesn't matter how you call it, just make sure to reference the correct file.

See the code below.

Ext.
 
	 simple =  Ext..
 
 
        standardSubmit: ,
 
 
        frame:,
        title: ,
 
        width: ,
        defaults: width: ,
        defaultType: ,
		items: 
                fieldLabel: ,
                : ,
                allowBlank:
            ,
			
                inputType: ,
                id: ,
                : ,
                value: 
            
 
        ,
        buttons: 
            text: ,
            handler:  
		simple.... = ;
	        simple.... = ;
                simple..;
            
        
 
 
    ;
 
 
 
    simple.;
 
 
 
;

Important part of this script are:

  • The "standardSubmit: true" line, which will make sure the form is submitted via the standard way
  • The handler for the submit button. At first I thought adding "standardSubmit: true" would be sufficient, but it's not.
  • simple.render() says where the form should be places. if you change the id of the <div> tag in your html, don't forget to change this name too
目录
相关文章
|
XML JSON 数据处理
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
406 0
postman 中 body的form-data,x-www-form-urlencoded,raw,binary含义
|
2月前
form-data 与 x-www-form-urlencode有何区别?
在客户端和服务器之间传递数据既可以使用`form-data` ,又可以使用 `x-www-form-urlencoded` 。但是在使用时你有注意它们的区别吗?
|
4月前
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
使用Form报错提示If ngModel is used within a form tag, either the name attribute must be set or the form
|
5月前
form常用
form常用
|
7月前
|
存储 文件存储 数据库
orbeon form 的配置介绍
orbeon form 的配置介绍
40 0
|
前端开发 JavaScript Java
【前端】form标签multipart/form-data 文件上传表单中 传递参数无法获取的原因
form标签multipart/form-data 文件上传表单中 传递参数无法获取的原因
724 1
JavaWeb - HTML表单提交数据 application/x-www-form-urlencoded 和 multipart/form-data 区别
JavaWeb - HTML表单提交数据 application/x-www-form-urlencoded 和 multipart/form-data 区别
166 0
|
前端开发
|
JavaScript 前端开发