Jump to content

[SOLVED] HTML <select><option....>


snorky

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/164200-solved-html/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-866181
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-868146
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/164200-solved-html/#findComment-870027
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.