简体   繁体   中英

Submit without submit button

I have created dropdown menu "Users", whith 2 options to select

<select name="Users">
        <option>User1</option>
        <option>User2</option>
</select>

I'm stuck with next thing i want to do, which is: -if user1 is selected, another dropdown menu is generated -if user2 is selected, input windows is generated

I would like changes to be made without submit button. Changes should be made with selection on "users" dropdown menu.

Any tips or solution will be greatly appreciated!

You need Javascript http://www.w3schools.com/js/default.asp

PHP is server side language and it generates code only while user is loading the page not after its already loaded. If you want users to get code inside their browser, after some their action you need User side language as Javascript.

It will be easier for you if you use some Javascript library as jQuery http://www.jquery.com .

你应该使用jQuery事件并使用select box的change事件来显示和隐藏你想要的任何html元素。

<select name="Users" onchange="this.form.submit();">
        <option>User1</option>
        <option>User2</option>
</select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM