Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Asking about using Combobox

    Dear PHP master,
    I am newbie in PHP.
    I have question so far about creating combobox.

    The case :
    I need to use a combobox in login page.
    Such us:

    Login as : [ Administrator, Operators, Users ];
    Password : [password];

    value of Login As (Administrator, Operators, Users) put on a combobox.

    When we choose Login as Administrator, nothing will be changed.
    But when we choose Login as Operator, there will be changed in the bottom of Login As form. The location of Operator will be showed.

    Be like:
    Login as : Operator ;
    Location : [Nevada, Illinois, New York] ;
    Password : [password];

    Value of Location also put on a combobox.


    Does anybody know how to create code for this case?
    Hopefully the case was explained well.
    Please help me. Thanks.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    1. Combo boxes are a new addition in HTML 5. To get them to work web browsers that don't yet support it you need JavaScript to link the list part of the combo box to the input box part.

    Or did you mean a select list where the user must enter one of the entries in the list and doesn't have the additional option of entering their own.

    2. Any changes you want to make based on a selection in one box (whether it is a combobox or a select liist) means you need to reload the page from the server with those changes applied. You would test the value of the first box when displaying the page in order to display the content appropriate to that selection. You might also use JavaScript to make the changes in place but you can't rely on that and so should have the PHP reload of the page set up to allow the update to happen when JavaScript isn't available.
    Last edited by felgall; 01-25-2012 at 07:30 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    1. Combo boxes are a new addition in HTML 5. To get them to work web browsers that don't yet support it you need JavaScript to link the list part of the combo box to the input box part.

    Or did you mean a select list where the user must enter one of the entries in the list and doesn't have the additional option of entering their own.
    I mean when a list is selected, the sub of the list will be showed in bottom of the list.
    just like example: when Operator is selected, the sub values of the Operator, the list of Location of Operator will be showed up.

    If Administrator is selected, nothing will be changed because it dosn't have any sub values.


    2. Any changes you want to make based on a selection in one box (whether it is a combobox or a select liist) means you need to reload the page from the server with those changes applied. You would test the value of the first box when displaying the page in order to display the content appropriate to that selection. You might also use JavaScript to make the changes in place but you can't rely on that and so should have the PHP reload of the page set up to allow the update to happen when JavaScript isn't available.
    Any code suggestion for me ?

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    For some ideas on how to update it in the browser itself using JavaScript see http://www.felgall.com/jstip22.htm

    For the server side version when reloading the page you'd simply use the value that the first select already contains to determine what to display under it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    For some ideas on how to update it in the browser itself using JavaScript see http://www.felgall.com/jstip22.htm

    For the server side version when reloading the page you'd simply use the value that the first select already contains to determine what to display under it.
    thanks for your suggestion.
    let me check and try it first.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •