Two “form action's” on one line

…衆ロ難τιáo~ 提交于 2019-12-12 14:35:10

问题


I have just finished putting a login and register bit on my website and now I'm just cleaning things up, but then I came to this problem I have two form action's on one page, each one goes to a different page, easy enough, but I can't seem to get them both on one line.

Here is the code for the form actions:

<form action='logout.php' method='POST'>           
<input type='submit' value='Logout' />      
</form>                      
<form action='changepassword.php' method='POST'>     
<input type='submit' value='Change password' />       
</form>

I've tried

<form action='logout.php' method='POST'>           
<input type='submit' value='Logout' />                           
<form action='changepassword.php' method='POST'>     
<input type='submit' value='Change password' />       
</form>

but both buttons go to the same location

the website is www.crossception.com, you will need to login to get to this problem I've already made a login and password for every one to use username : stackoverflow password : test101

thank you very much
connor
(aged 15)


回答1:


<span style="float:left;">
    <form action='logout.php' method='POST'>           
        <input type='submit' value='Logout' />      
    </form>   
</span>
<span style="float:right;">
    <form action='changepassword.php' method='POST'>     
        <input type='submit' value='Change password' />       
    </form>
</span>



回答2:


If I understand your question properly, I think you need to use some CSS:

form {
    float: left;
    width: auto;
}

You might want to add a class to those forms to stop yourself styling all forms like this




回答3:


Here's the dirty inline version

<form action='logout.php' method='POST' style='float:left;'>           
<input type='submit' value='Logout' />      
</form>                      
<form action='changepassword.php' method='POST'>     
<input type='submit' value='Change password' />       
</form>

Of course James's suggestion to use a class is the proper way to do it.

Btw, those forms should be after the opening body tag.



来源:https://stackoverflow.com/questions/6486853/two-form-actions-on-one-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!