今天工作上正好用到,其实是个伪单点登录,只是把同一个表单发到不同的页面而已
先写 2 个函数,用来将 action 的 url 分开
1 2 3 4 5 6 7 8 9 10
| function firstFormSubmit() { document.form1.action = "login.jsp"; document.form1.submit(); } function secondFormSubmit() { document.form1.action = "chklogin.jsp"; document.form1.username.value = form1.userid.value; document.form1.password.value = form1.userpassword.value; docuemnt.form1.submit(); }
|
表单如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <form name="”form1″" method="”post”"> <input name="”userid”" type="”text”" size="”17″" /> <input name="”userpassword”" type="”password”" size="”17″" /> <input name="”password”" type="”hidden”" size="”17″" /> <input name="’aa’" type="’button’" value="”提交1″" onClick="firstFormSubmit()”" /> <input name="’bb’" type="’button’" value="”提交2″" onClick="secondFormSubmit()" ‘ /> </form>
|