I am creating a form in which a user selects an event from a <select> menu and if the event is password protected, a code box will appear below.
The problem is that the list is generated from the server on a mysql page. What I am trying to do is make the box appear only if it is password protected. My first idea was to set the value of the protected options to "protected" or something similar, but this won't work as I will lose the value it is supposed to be.
Since you're already using Javascript you could have an object containing event details, an effective model. You could then just have an index as the value for each option and the javascript looks up the appropriate information in the model for the selected event.
I think that's the best option, personally. You could also do it by assigning non-standard tags to the various options.
I was considering the "non-standard tag" method by using class or id, but then I realized that I had no idea how to retrieve which option class or option id was selected.
Any ideas for that method?
Further, I build an array with the values that should be protected, but wasn't sure how I was going to go about checking to see if the value selected was on the list. Any ideas for this method?
After doing some searching, I came across in_array(), and I am going to try to use the generated array with the protected values and the in_array() function to check if the selected value is in the array.
Bookmarks