好看的表单源码
㈠ android平板 怎么设计好看的表单
1.来说下主程序MainActivity.java
public class MainActivity extends Activity {
	private TableLayout table;
	private Button select;
	EmployeeDao  = new EmployeeDao(this);
	private Button add;
	private Button update;
	int selectedRow = 0;
	int ActivityID=1;
	List<Employee> list = new ArrayList<Employee>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		table = (TableLayout) this.findViewById(R.id.table);
		table.setBackgroundColor(Color.GREEN);
		//table.set
		add = (Button) this.findViewById(R.id.add);
		update = (Button) this.findViewById(R.id.update);
		select = (Button) this.findViewById(R.id.select);
		// 点击查询按钮处理事件
		// Toast.makeText(this, "已查询过了!", Toast.LENGTH_SHORT).show();
		select.setOnClickListener(new selectListener());
		// 点击添加按钮事件处理,跳转到另一个activity
		add.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent();
				i.setClass(MainActivity.this, AddAndUpdateActivity.class);
				Bundle bundle=new Bundle();
				ActivityID=1;
				bundle.putInt("ID", ActivityID);
				i.putExtras(bundle);
				startActivity(i);
			}
		});
		// 更新员工信息
		update.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent();
				i.setClass(MainActivity.this, AddAndUpdateActivity.class);
				Bundle bundle=new Bundle();
				ActivityID=2;
				bundle.putInt("ID", ActivityID);
				bundle.putInt("emID", selectedRow);
				i.putExtras(bundle);
				startActivity(i);
			}
		});
	}
	// 查询信息监听类
	private class selectListener implements View.OnClickListener {
	@Override
	public void onClick(View v) {
	list = .getAll();
		if (list.size() != 0) {
			for (int i = 0; i < list.size(); i++) {
			   TableRow row = new TableRow(MainActivity.this);
			Employee em = list.get(i);// 查找所有员工信息
			// 设置行标记
			row.setId(em.getId());
			row.setPadding(6, 1, 6, 1);
			row.setGravity(Gravity.CENTER);
			row.setBackgroundColor(Color.WHITE);
			TextView view1 = new TextView(MainActivity.this);
			view1.setText(Integer.toString(em.getId()));
			view1.setGravity(Gravity.CENTER);//文本居中
			view1.setTextSize((float) 18);文本大小			
                           view1.setTextColor(Color.RED);
			view1.setPadding(10, 2, 10, 2);//边框左、上、右、下
			row.addView(view1);添加一行
			TextView view2 = new TextView(MainActivity.this);
			view2.setText(em.getName());
			view2.setTextSize((float) 18);
			view2.setPadding(10, 2, 10, 2);
			row.addView(view2);
			TextView view3 = new TextView(MainActivity.this);
			view3.setText(Integer.toString(em.getAge()));
			view3.setTextSize((float) 18);
			view3.setGravity(Gravity.CENTER);
			view3.setPadding(10, 2, 10, 2);
			row.addView(view3);
			TextView view4 = new TextView(MainActivity.this);
			view4.setText(em.getPosition());
			view4.setTextSize((float) 18);
			view4.setPadding(10, 2, 10, 2);
			row.addView(view4);
			TextView view5 = new TextView(MainActivity.this);
			view5.setText(em.getDepartment());
			view5.setTextSize((float) 18);
			view5.setPadding(10, 2, 10, 2);
			row.addView(view5);
			TextView view6 = new TextView(MainActivity.this);
			view6.setText(em.getWorkdate());
			view6.setTextSize((float) 18);
			view6.setPadding(10, 2, 10, 2);
			row.addView(view6);
			TextView view7 = new TextView(MainActivity.this);
			SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
			Date date = null;
				try {
					date = format.parse(em.getWorkdate());
				} catch (ParseException e) {
					e.printStackTrace();
				}
				float d= (float)((new Date().getTime()-date.getTime())/(24*60*60*1000)/365);//计算工龄
				String dd=Integer.toString((int) d+1);
				view7.setText(dd);
				view7.setTextSize((float) 18);
				view7.setPadding(10, 2, 10, 2);
				row.addView(view7);
				table.addView(row);
				row.setOnClickListener(new View.OnClickListener() {//点击某行触发事件
					@Override
					public void onClick(View v) {
						System.out.println("行标记:" + v.getId());
						for (int i = 0; i < table.getChildCount(); i++) {
							if (table.getChildAt(i).getId() != v.getId())
								table.getChildAt(i).setBackgroundColor(Color.WHITE);
								// 选中时,高亮显示即设置背景色
								v.setBackgroundColor(Color.YELLOW);
							}
							selectedRow = v.getId();
							AlertDialog.Builder dialog = new AlertDialog.Builder(
									MainActivity.this);
							dialog.setTitle("请确认:");
							dialog.setMessage("是否删除这条记录?");
							dialog.setPositiveButton("确定",
							new DialogInterface.OnClickListener() {
								@Override
								public void onClick(
								DialogInterface dialog,int which) {
								EmployeeDao  = new EmployeeDao(MainActivity.this);
								.delete(selectedRow);
								Toast.makeText(MainActivity.this,
									"删除成功", Toast.LENGTH_SHORT).show();
								Intent i = new Intent();
								i.setClass(MainActivity.this,MainActivity.class);
								startActivity(i);
									}
								});
							dialog.setNegativeButton("取消",
								new DialogInterface.OnClickListener() {
									@Override
									public void onClick(DialogInterface dialog,
										int which) {
										dialog.cancel();
									}									                            });
				                           dialog.show();
						}
					});
				}
			}
		}
	}
}
2.然后是添加和更新的界面,两个功能使用同一个xml文件布局
 
<RelativeLayout     
    android:background="#2691f2"
     tools:context=".AddAndUpdateActivity" >
    <TextView
        android:id="@+id/t"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:textSize="25sp"
        android:text="@string/addinfo"
        android:textColor="#bc4b86" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/t"
        android:orientation="vertical" >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp" />
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/name" />
            <EditText
                android:id="@+id/nm"
                android:inputType="text"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="25dp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/age" />
            <EditText
                android:id="@+id/ag"
                android:inputType="text"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="25dp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/position" />
            <EditText
                android:id="@+id/pzs"
                android:inputType="text"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="25dp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/dptmt" />
            <EditText
                android:id="@+id/dptmt"
                android:inputType="text"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="25dp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/date" />
            <EditText
                android:id="@+id/wkdt"
                android:inputType="text"
                android:layout_width="150dp"
                android:layout_height="wrap_content" />
        </LinearLayout>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="20dp" />
        <Button
            android:id="@+id/addnew"
            android:layout_width="60dp"
            android:layout_height="40dp"
            android:layout_gravity="center_horizontal"
            android:text="@string/add" >
        </Button>
    </LinearLayout>
</RelativeLayout>
㈡ HTML 表单提交 的简单代码
1、打开Dreamweaver编辑器,准备好一个空白的html文件,写入基本的html结构:

㈢ 设计如下一个表单页面,写出相应的代码。
表单是实现动态网页的一种主要的外在形式。表单和表单域并不具有排版的能力,表单网页的制作最终还是要由表格组织起来。html表单是html页面与浏览器端实现交互的重要手段。利用表单可以收集客户端提交的有关信息。 在浏览网站时经常会遇到表单,它是网站实现互动功能的重要组成部分。无论网站使用的是那种形式的语言来实现网站的互动功能,例如ASP、php、JSP,表单已经成为它们统一的外在形式。 表单的主要功能是收集信息,具体说是收集浏览者的信息。例如在网上要申请一个电子信箱,就必须按要求填写完成网站提供的表单页面,其主要内容是姓名、年龄、联系方式等个人信息。又例如要在某论坛上发言,发言之前要申请资格,也是要填写完成一个表单网页。 表单可以用于调查、订购、搜索等功能。一般的表单由两部分组成,一是描述表单元素的html源代码,二是客户端的脚本,或者服务器端用来处理用户所填信息的程序。在html里,我们可以定义表单,并且使表单与CGI或ASP等服务器端的表单处理程序配合。 表单信息处理的过程为:当单击表单中的提交按纽时,输入在表单中的信息就会上传到服务器中,然后由服务器中的有关应用程序进行处理,处理后或者将用户提交的信息储存在服务器端的数据库中,或者将有关的信息返回到客户端浏览器中。 表单是网页上的一个特定区域。这个区域是由一对<Form>标记定义的。这一步有几方面的作用。第一方面,限定表单的范围。其它的表单对象,都要插入到表单之中。单击提交按纽时,提交的也是表单范围之内的内容。第二方面,携带表单的相关信息,例如处理表单的脚本程序的位置、提交表单的方法等。这些信息对于浏览者是不可见的,但对于处理表单确有着决定性的作用。 基本语法01 <Form name="Form_name" method="method" action="url" enctype="value" target="target_win"> 02 …… 03 </Form> 语法解释<Form>标记的属性如下表所示 属性 描述 name 表单的名称 method 定义表单结果从浏览器传送到服务器的方法,一般有两种方法:get和post action 用来定义表单处理程序(ASP,CGI等程序)的位置(相对地址或绝对地址) enctype 设置表单资料的编码方式 target 设置返回信息的显示方式 <FORM>标记的ENCTYPE属性基本语法01 <Form enctype="value"> 02 …… 03 </Form> 语法解释value的取值如所下表所示 属性值 描述 Text/plin 以纯文本形式传送信息 Application/x-www-Form-urlencoded 默认的编码形式 Multipart/Form-data 使用mine编码 文件范例:11-4.htm设置表单信息提交的编码方式。01 <!-- ------------------------------ -->02 <!-- 文件范例:11-4.htm -->03 <!--文件说明:设置信息提交的编码方式-->04 <!-- ------------------------------ -->05 <html>06 <head>07 <title>设置信息提交的编码方式</title>08 </head>09 <body>10 <h1>用户调查</h1>11 <Form name=invest action=mailto:[email protected] method=get enctype=text/plain>12 </Form>13 </body>14 </html>
㈣ 写出对应网页的HTML源代码
代码如下:
<form class="" >
<table border="2">
<tr>
<td>用户姓名:</td>
<td><input type="text" name="name" ></td>
<td><strong>*必须输入</strong></td>
</tr>
<tr>
<td>用户密码:</td>
<td><input type="password" name="name" ></td>
<td><strong>*必须输入</strong></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input name="" type="checkbox" value="" checked="checked" />记住我的信息</td>
</tr>
<tr>
<td colspan="3">
<伍脊input name="昌清" type="submit" value="提交" />
<input name="" type="button" value="重置" />
</td>
</tr>
完全按照图片上来做的,但是只用html应该不能进行提交,这涉及到cookie,需要php或者其他东西,所以提交只是做做样子。
这是效果耐橘前截图:

