
![]() |
perkiset
OK this is probably silly and old hat for a lot of you, but I started doing something new today and I like it both for clarity and speed.
If I have a dynamic SELECT in a form, I've used two different methods to populate it: either I ajaxed an answer or had myPHPcreate JS code that was on page ... something like this:myArr[0] = 'entry0'; myArr[1] = 'entry1'; ... and so forth. It works but is pretty damn ugly- particularly in the case of multiply-dimensioned and shaped arrays. I use JSON when I send data back via AJAX, so I simply combined the two and got nice tight code that I like. After I create <whatever the array is to look like> inPHP, then I json_encode it and place this single line in my outgoing HTML:brands = eval($theEncodedBrandsString); What comes out in the final HTML looks like this: brands = eval({"1":{"name":"Palace Resorts","properties":[{"id":"1","name":"Moon Palace"}]}}); ... which is ugly, but wicked fast. Just a gear turner and ![]() /p |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads