一个表单中的两个图像按钮..如何给出代码..? [英] Two image buttons in one form..how to give a code..?

查看:72
本文介绍了一个表单中的两个图像按钮..如何给出代码..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在登录表单中有两个图像按钮登录和注册。如果我点击登录按钮,那么它应该重定向页面secure.php。如果我点击注册按钮然后它应该重定向页面registration.php。



你可以解释或给出一个解决方案..如何给表单代码。 ..?

解决方案

如果您坚持将表单发布到不同的操作,您应该不提供原始操作属性,但在提交前单击设置,并提交您的用javascript形成。这与php无关,甚至与MySQL无关。



 <   script     type   =  text / javascript    src   =  http://ajax.aspnetcdn.com/ajax/jQuery/ jquery-1.8.3.min.js >  <   / script  >  
< form name = login-or-register id = login-or-register 方法 = 发布 >
< 标签 = name-field > 名称:< / label >
< input 类型 = text 名称 = name-field id = name-field >

< 按钮 type = 按钮 id = register > 注册< / button >
< 按钮 类型 = 按钮 id = 登录 > 登录< / button >
< / form >
< ; script type < span class =code-keyword> = text / javascript >


(function(){


(#register)。click(function(event){

Hi,
in a login form there is two image buttons login and register. if i click on login button then it should redirect the page secure.php. if i click on register button then it should redirect the page registration.php.

can u just explain or give a solution.. how to give a code for form...?

解决方案

If you stick to post your form to different actions, you should give no original action property, but set it on click before submit, and submit your form with javascript. This has nothing to do with php, even less with MySQL.

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>
<form name="login-or-register" id="login-or-register" method="post">
 <label for="name-field">Name:</label>
    <input type="text" name="name-field" id="name-field">

 <button type="button" id="register">Register</button>
 <button type="button" id="login">Login</button>
</form>
<script type="text/javascript">


(function () {


("#register").click(function (event) {


这篇关于一个表单中的两个图像按钮..如何给出代码..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆