snorky Posted June 30, 2009 Share Posted June 30, 2009 How do I add an editable 'option' to a list of hard-coded options? <select type='text' tabindex='".++$tindex."' name='bldg' style='position:absolute;left:175px; border:thin solid black;' /> <option value ='".$bldg."' selected='selected'>".$bldg."</option> <option value ='ASC'>ASC</option> <option value ='BVE'>BVE</option> <option value ='CHE'>CHE</option> <option value ='HCE'>HCE</option> </select> I want to add a "blank" line that the user can edit in the event that none of the hard-coded choices fits. Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/ Share on other sites More sharing options...
haku Posted June 30, 2009 Share Posted June 30, 2009 You can't make an option editable. There are a few options here that can mimic what you want to do however. * You can add an 'other' option (<option value="other">other</option>), and a textbox below that says 'fill in this textbox if you chose 'other'' or something like that. * You can create an ajax popup that pops up when 'other' is selected, allowing the user to enter the value into that. You can then use javascript to change the value of the 'other' element to whatever it is that the user entered * You can do almost the same thing as above, but instead of a popup, you add the 'other' textfield below the dropdown if 'other' is selected. Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-866181 Share on other sites More sharing options...
snorky Posted July 2, 2009 Author Share Posted July 2, 2009 THX. I tried your auxiliary text box idea. It works great. And less filling.... Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-868033 Share on other sites More sharing options...
TheFilmGod Posted July 3, 2009 Share Posted July 3, 2009 Why would you allow the user to create their own option? That completely defeats teh person of having a list of options to begin with. Just use a text input then... ??? Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-868119 Share on other sites More sharing options...
haku Posted July 3, 2009 Share Posted July 3, 2009 Not necessarily. You may want to group users replies together as best as possible. So you provide options, but if the user's selection doesn't exist, they can create a new one, which future users could then select from the list, keeping them grouped. Or maybe just for the sake of ease-of-use for the users - you may find that 99% of the time the user's selection is part of the list, with the remaining 1% of the time it being something not on the list. So why make 99% of the users take the time to type it out for that remaining 1% of the users? Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-868146 Share on other sites More sharing options...
snorky Posted July 6, 2009 Author Share Posted July 6, 2009 Why would you allow the user to create their own option? That completely defeats teh person of having a list of options to begin with. Just use a text input then... ??? There are several forms and reports that use the same database. One of the forms is where users can make edits the the database, and only few trusted users can access it. The people who use the data for reports don't see the 'pick list' in question. However, I solved the problem AND made the menu slicker by coding in a list that is dynamically generated when the form is opened. The code for that page does a SELECT DISTINCT ... ORDER BY... on the field in question, uses a foreach loop, and spins out a <SELECT><OPTION> menu that is always current. If there is a need for a new value to add to the list, there's a field in the form that enables adding a new value (as huku suggested above). Once that form posts, the next time someone accesses that page, they'll get the latest version of the menu. The menu is a no-maintenance item for me (I don't have to go into the code to add or delete items from the list). Back to the read-only people .... they use a form to select the criteria for the report that they want to see. I could give them the same pick list (read only), but with 35 or so items (and growing), it's unwieldly. Instead I give them a text field to enter the criteria, and evaluate their entries by using a SELECT ... FROM ... WHERE ... LIKE "%nnnn%" ... ORDER BY statement. That's my "Horseshoes" code. It counts even if they're close. Examples: User wants to see a list of custodians, but can't spell 'custodian'. The pick list would by way too long, e.g., 35 items. but if the user enters 'cust' in the test box, they'll get a list of custodians and customers. If the report is too long, the user can see how to spell 'custodian', and enter that to narrow the search. If the user enters 'sec' the user gets a list of secretaries and section_leaders. 'uperv' gets the supervisors and so on. Everyone seems happy with the program. Quote Link to comment https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-870027 Share on other sites More sharing options...
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.