RE: [PHP] scroll down list -visible, but not possible to choose
Date: Wed, 31 Aug 2011 04:30:56 -0400 From: rob...@myself.com To: php-general@lists.php.net Subject: [PHP] scroll down list -visible, but not possible to choose Hi, Got so excellent and fast help last time so trying again here I have the below function with array for satus of issues where I need to have 'Resolved/Closed' visible but not available for choice This as closing is a separate function to ensure correct resolution code is selected Already tried removing 'Resolved', and got everything working only to notice when testing that when viewing issues the Resolved ones showed up as 'Support Working' even though closed in the system function print_statuses($selected) { $statuses = array('Resolved','Support Working','Waiting on Customer','New','Read Update'); foreach($statuses as $status) { echo option value=\$status\; if($status == $selected) echo ' selected'; echo $status/option; } } The HTML attribute 'disabled' for the option tag might help you out here. Another option would be to catch off selection of the 'Resolved' state when parsing the submission of the form. Lastly you could alter the script to display something else instead of the selection box when the 'Resolved' state applies. Personally I think the latter is the most elegant solution. Regards, Jasper
Re: [PHP] scroll down list -visible, but not possible to choose
You want: if($status == $selected) echo selected = ' selected' ; (I didn't bother with \s) And BTW, unless the support person is actually sitting on top of the customer (and I can see situations where that would help), you want it to say Waiting *for* Customer Ken On Wed, Aug 31, 2011 at 3:30 AM, rob...@myself.com wrote: echo option value=\$status\; if($status == $selected) echo ' selected'; echo $status/option; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scroll down list -visible, but not possible to choose
On Wed, 31 Aug 2011, rob...@myself.com wrote: I have the below function with array for satus of issues where I need to have 'Resolved/Closed' visible but not available for choice This as closing is a separate function to ensure correct resolution code is selected Already tried removing 'Resolved', and got everything working only to notice when testing that when viewing issues the Resolved ones showed up as 'Support Working' even though closed in the system There are two possible points of failure here, your code and browser behaviour. Whenever I'm faced with this sort of problem, I look at the source code in my browser to see the HTML my code generates. Then I can determine if my code is outputting what I'd intended. If it is, then my code is right but the implementation is wrong, as the correct HTML produces the incorrect result. If you'd done this, you'd have seen what the problem is. The problem is that, having taken away Resolved as a possible option, all items marked Resolved are unable to be listed as selected. Consequently no items are selected and the browser defaults to the first item in the list which is Support Working. I've never had to do this, but http://www.w3schools.com/TAGS/tag_option.asp says you can use the disabled attribute to disable an option. So your resulting HTML could look like this: option value=Resolved disabledResolved/option or option value=Resolved disabled selectedResolved/option as appropriate. A simple if statement could be used to set the disabled attribute for the Resolved selection only. IMHO this is vastly preferable to any trickery you may use with javascript to prevent the user from selecting Resolved. I've never struck a select field like this and am now interested in coding one up just to see how it works in practice. HTH, Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php