<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>form.html</title><metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="this is my page"><metahttp-equiv="content-type"content="text/html; charset=UTF-8"></head><body><formname="form1"action="test.html"method="post"><inputtype="text"name="username"value="zhang" /><inputtype="button"name="ok"value="保存1"/></form><formname="form2"action="test1.html"method="post"><inputtype="text"name="username"value="zhang2" /><inputtype="button"name="ok2"value="保存2"/></form></body><scriptlanguage="JavaScript">//使用两种方式输出表单的action值 (使用表单的名称,使用表单数组forms)//方法一:document.表单名var form1 = document.form1;
//alert(form1.action);//使用两种方式输出表单的method的值(使用表单数组forms,使用表单数组forms)//方法二:document.forms[索引值](表单对象)var form2 = document.forms[1];
alert(form2.action);
</script></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>form.html</title><metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="this is my page"><metahttp-equiv="content-type"content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--></head><body><formname="form1"action=""method="post">
患者姓名:<inputtype="text"name="username"value="zhang" /><inputtype="button"name="ok"value="打印患者信息"onclick="printPerson()" /><inputtype="button"name="ok"value="查询患者信息"onclick="selectPerson()" /></form></body><scriptlanguage="JavaScript">//通过javaScript函数的方式访问printPerson.html和selectPerson.htmlfunctionprintPerson(){//1. 获取表单var form1 = document.form1;
//2. 设置表单的action属性
form1.action = "printPerson.html";
//3. 提交表单
form1.submit();
}
functionselectPerson(){var form1 = document.forms[0];
form1.action = "selectPerson.html";
form1.submit();
}
</script></html>