Andrew110m 0 Posted May 31, 2011 Report Share Posted May 31, 2011 Hi guys, I want to start by announcing the obvious, that I'm a noob at this stuff. I'm looking for a function on a form that would give a list of options...Option AOption BOption CThen when someone submits a form selecting an option, that option is removed automatically from the list.So User X selects A, when User Y views the form he/she seesOption BOption CAs selectable fields. Is there anyway to have this done automatically? Or would I just have to remove the options manually?Thanks in advance. Quote Link to post Share on other sites
Ingolme 1,032 Posted May 31, 2011 Report Share Posted May 31, 2011 You need PHP or another server-side language to do that, and a place to store the options such as a file or a database. Quote Link to post Share on other sites
Andrew110m 0 Posted May 31, 2011 Author Report Share Posted May 31, 2011 You need PHP or another server-side language to do that, and a place to store the options such as a file or a database.How difficult would that be to put together? Is there a tutorial on here showing how to create such a form? Quote Link to post Share on other sites
thescientist 231 Posted May 31, 2011 Report Share Posted May 31, 2011 to have it propagate for multiple users over multiple sessions, you will probably want to save the options selected in a file or ideally in a database. With a database, you can store all the options, and then when a user selects one, just turn a flag off in the database so that it won't be seen on the page anymore. to re-enable it, you can just manually set it back yourself.so, to get the selection to the database, you would have to use an event handler to detect a selection made, and then send that value (via AJAX most likely) to a server-side script that can make the appropriate changes in the database.Other wise you can do it manually in the markup, or in a file, or whatever else works for you. Quote Link to post Share on other sites
Andrew110m 0 Posted May 31, 2011 Author Report Share Posted May 31, 2011 I appreciate the explanation, but to be honest, you lost me.I am really not very talented at PHP or any other coding languages. Is there some kind of tutorial that could help me put something like this together or would I need someone with a better knowledge of the coding? I was hoping to use this for one of my websites, but it isn't a necessity. If it would be possible for anyone to really simplify it for me, it would be greatly appreciated. If not, thank you for your efforts. Quote Link to post Share on other sites
Ingolme 1,032 Posted May 31, 2011 Report Share Posted May 31, 2011 There are two kinds of tutorials: The ones that simply give you all the code with one or two comments explaining it, and the ones that explain all about the language but expect you to build the code yourself from what they explained.The first kind of tutorials are convenient for people who don't want to learn, but here at W3Schools we intend to teach people. The tutorials at W3Schools are there to teach you the language. You should learn PHP first and then try to discover on your own how to make the feature you want. Quote Link to post Share on other sites
Andrew110m 0 Posted June 1, 2011 Author Report Share Posted June 1, 2011 I wasn't really looking for the easy way out. I've self-taught myself everything I know up until this point and I've often used W3Schools for help.All I was looking for was a little guidance and a point in the right direction. I'll see if I can figure it out. Thanks. Quote Link to post Share on other sites
thescientist 231 Posted June 1, 2011 Report Share Posted June 1, 2011 I appreciate the explanation, but to be honest, you lost me.I am really not very talented at PHP or any other coding languages. Is there some kind of tutorial that could help me put something like this together or would I need someone with a better knowledge of the coding? I was hoping to use this for one of my websites, but it isn't a necessity. If it would be possible for anyone to really simplify it for me, it would be greatly appreciated. If not, thank you for your efforts.Well, there are probably a few ways to do this, so there will be differing opinions. I guess the main questions is how much work do you want to do upfront? How many selections will there be? Do you anticipate users selecting all the selections, so that the drop down could be empty at some point? Would you want an easy way to add/remove/update possible values in this drop down menu? Quote Link to post Share on other sites
Andrew110m 0 Posted June 1, 2011 Author Report Share Posted June 1, 2011 Well, there are probably a few ways to do this, so there will be differing opinions. I guess the main questions is how much work do you want to do upfront? How many selections will there be? Do you anticipate users selecting all the selections, so that the drop down could be empty at some point? Would you want an easy way to add/remove/update possible values in this drop down menu?I suppose it would be easiest to tell you exactly what its for. I run a video game league and what I want is for people to be able to select/"claim" a fighter from the roster and for that fighter to then be removed from the list of available fighters.Hypothetically, the drop down could be empty at some point. The easier to edit the values in the drop down menu the better. I expect that there will be fighters becoming available and unavailable quite frequently. Where it gets a little complicated is if possible I'd like users to be able to narrow it down by weight class. So for example, say they want to select a heavyweight fighter. They select the heavyweight division and then the drop down menu below is fighters from only the heavyweight division.I created a database using mySQL. My thought would be that I have to then create tables within for each weight class and each table contains the fighters of that weight class.Am I on the right track here? Quote Link to post Share on other sites
trevelluk 0 Posted June 1, 2011 Report Share Posted June 1, 2011 The more usual approach would be to have two tables, weight_class and fighter. Add a primary key to weight_class, and then add a weight_class_id column to fighter containing the primary key of the appropriate weight class. E.g. something like this: weight_class---------------id | name---------------1 | heavyweight2 | middleweight3 | lightweight----------------fighter---------------------------weight_class_id | name---------------------------3 | small guy1 | big guy--------------------------- So from this, you could tell that "big guy" is in the heavyweight class, and "small guy" is in the lightweight class.The big advantage of this scheme is you don't need to add a new table every time you want to add a new weight class. Quote Link to post Share on other sites
Andrew110m 0 Posted June 1, 2011 Author Report Share Posted June 1, 2011 Okay, so I created two tables.weight_idPrimary key = id (1-5 for weight classes)weightfighterPrimary key = fighter nameweight idfighter overallSo based on the other suggestions here I have been trying to create a php/ajax file that will call up this table. I've been using this page for guidance: http://www.w3schools.com/php/php_ajax_database.aspFigured if I could get that down, I would be on my way to accomplishing what I'm looking for. Am I on base with the tables? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.