Login   Register  
PHP Classes
elePHPant
Icontem

How to disable a select option

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      HtmlForm PHP 5  >  All threads  >  How to disable a select option  >  (Un) Subscribe thread alerts  
Subject:How to disable a select option
Summary:How to disable a select option
Messages:18
Author:w. studer
Date:2013-02-06 16:16:07
Update:2013-02-13 10:53:16
 
  1 - 10   11 - 18  

  11. Re: How to disable a select option   Reply  
Picture of w. studer
w. studer
2013-02-12 15:43:07 - In reply to message 10 from Sebastian Schlapkohl
Woah, again ...

Thanks a lot.

Just complete something, then I will give it a try.


  12. Re: How to disable a select option   Reply  
Picture of Sebastian Schlapkohl
Sebastian Schlapkohl
2013-02-12 15:55:54 - In reply to message 11 from w. studer
Should be complete now.

  13. Re: How to disable a select option   Reply  
Picture of w. studer
w. studer
2013-02-12 19:13:30 - In reply to message 12 from Sebastian Schlapkohl
Tested with SELECT and works fine.

Thanks a lot again.


Just one point, where some people may get confused:
In case the options key is a numeric value, then I can not use for disabled array/value the numeric option key, because it is interpreted as index.

For me it was easy to find the workaround here.


  14. Re: How to disable a select option   Reply  
Picture of Sebastian Schlapkohl
Sebastian Schlapkohl
2013-02-12 19:31:30 - In reply to message 13 from w. studer
There should be a clear distinction between ints, which are indices, and int-strings, which are values. This seemed to work in my test cases, but I will look into that again.

  15. Re: How to disable a select option   Reply  
Picture of Sebastian Schlapkohl
Sebastian Schlapkohl
2013-02-12 20:29:59 - In reply to message 13 from w. studer
Hm, can't find anything wrong with setting of numerical values. I built expanded test cases and everything behaves as it should.

I changed the "testselectsingle" and the "testselectmultiple" explicitly to cover muddled indices and numerical values as single values as well as mixed array, but everything's all right so far.

You can have a look at it here:

http://sschlapkohl.1337server.com/htmlform/?examples

On the left you can view the current code base and in the right column you can execute exactly that code and see the testcases in action, based on the current version.

If this doesn't clear up the problem, please send me some source to look at, cause this would be unpleasant to put it mildly.

  16. Re: How to disable a select option   Reply  
Picture of w. studer
w. studer
2013-02-13 09:22:03 - In reply to message 15 from Sebastian Schlapkohl
Hi

I think I found the difference in means.

Example:
I have a table which contains records, having a numeric key field.
The records from this table I add into the options array, having the numeric key as array key:
>>$option[$mytable_fetch['key']] = $mytable_fetch['data'];
With data it looks like:
>>$option[5] = 'Hugo';

In case I use now same key for the disabling, I used:
>>$disabled[] = $mytable_fetch['key'];
With data it looks like:
>>$disabled[] = 5;

What I should do is:
>>$option["'" . $mytable_fetch['key'] . "'"] = $mytable_fetch['data'];
>>$disabled[] = "'" . $mytable_fetch['key'] . "'";
With data it looks like:
>>$option['5'] = 'Hugo';
>>$disabled[] = '5';


For me, a numeric key is a numeric value in the key field.
You differentiate between a numeric value as an Index and a numeric value in a string as a key.

Fine for me.

Thanks a lot

  17. Re: How to disable a select option   Reply  
Picture of Sebastian Schlapkohl
Sebastian Schlapkohl
2013-02-13 10:22:00 - In reply to message 16 from w. studer
Ah, now I see what's the problem, keys as well as the values for options are indeed always strings, you won't get anything different back from the Request anyway, so setting anything different here is useless. If I'm not misstaken I'm even casting keys and values to String for this.

BTW:casting something to String is much easier done like "$var" or ''.$var :)

  18. Re: How to disable a select option   Reply  
Picture of w. studer
w. studer
2013-02-13 10:53:16 - In reply to message 17 from Sebastian Schlapkohl
Oh, good to know.

Still a lot to learn of PHP ... ;-)

 
  1 - 10   11 - 18