dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: [RESOLVED] Auto Update <select> options based on other <select> options in the form

  1. #1
    Join Date
    Jun 2006
    Posts
    11

    resolved [RESOLVED] Auto Update <select> options based on other <select> options in the form

    Basically I have a system that has 8 users who each have their own station. Every few months they switch stations. So I have a table to holds the user and what station they are assigned to. Now what I want to do is have a webpage that I can have a list of all of the users and a dropdown select box next to their name where I can choose the station they are assigned to. I want to make it so when a station gets selected it removes that station from the other user's options. I know I should be able to do this with a loop in javascript but I haven't used javascript too much and I'm not entirely certain how to go about doing this.

    Can anybody help me with this? or at least point me in the right direction? If you have any questions just let me know!

    Thanks.

  2. #2
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    Basically I have a system that has 8 users who each have their own station. Every few months they switch stations. So I have a table to holds the user and what station they are assigned to.
    Unsure what you mean by "have their own station" and how exactly "switch stations" is determined? And "where I can choose the station they are assigned to" needs some clarification perhaps also. Are you talking about multiple users on same/different machines/and/or different logins? It sounds to me like you are looking for a server-side solution actually.

  3. #3
    Join Date
    Jun 2006
    Posts
    11
    I have 8 users, and 8 computers. Every few months they switch computers, so the database needs to be updated with their new locations. Here is a basic example of what it should look like http://ais-linux.uvu.edu/onestop/tes...ait/change.php

    That page doesn't do anything right now, but I want it so those dropdowns cannot ever possible have the same # selected. So if the first dropdown I choose station 2, I want the rest of the dropdowns to remove that option.

  4. #4
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    It sounds to me like you are looking for a server-side solution actually.
    As I said there... javascript is not the tool you want here. Should post this in the php forum. You are going to need to require users to login to the page via password and from there it would be relatively easy to determine which users view what from referencing an administrative page. But that is not the scope of this forum.

  5. #5
    Join Date
    Jun 2006
    Posts
    11
    This has nothing to do with the users needing to log in. This only has to do with the admin setting what the users are assigned to. What I want is the admin to only be able to select stations for users that are not currently in use. So the admin can't set user 1 to station 3 when user 7 is already set to station 3. So if I set user 1 to station 2, the drop down for user 2 would say "1, 3, 4, 5, 6, 7, 8" and then if I set user 2 to station 5 it would display this for user 3 "1,3,4,6,7,8" and so on. I should be able to do this with Javascript.

  6. #6
    Join Date
    Jun 2006
    Posts
    11
    Here is a picture showing kind of how it should work. In the first section, all 8 dropdowns show all 8 options. In the second section the first option has #3 selected so it no longers hows up in the rest of the dropdowns. In the 3rd section you have 3 select in the first dropdown and 6 selected in the next dropdown, so both of those options are removed from the remaining dropdown menus. I want to get this to happen without reloading the page.
    Last edited by aikepah; 02-10-2009 at 04:52 PM.

  7. #7
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,434
    Is this close to what you are looking for?
    See: http://javascript.internet.com/forms...wn-list-2.html

  8. #8
    Join Date
    Jun 2006
    Posts
    11
    Oh wow that is almost perfect! Thanks JMRKER! Little bit of work with that and I can make it do exactly what I need

  9. #9
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,434
    You're most welcome.
    Glad I was able to help. Post back if you have problems.
    Good Luck.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles