FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » to fill a select with json javascript from arrays
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: to fill a select with json javascript from arrays [message #175073 is a reply to message #175072] Wed, 10 August 2011 12:51 Go to previous messageGo to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma:
Senior Member
On 8/10/2011 2:13 PM, nawfer wrote:
> in JSON/javascript if I have 3 php’s array, how can insert their values in
> 3 selects?
> the select also must to be dependant; example Car Brand->Car
> Model->Accessories
> I look guide but cannot understand how solve the problem
>
>
> ARRAY BRAND
> brand[01]='Brand 1';
> ...
> brand[20]='Brand 20';
>
> ARRAY MODEL (every brand have 3 models,total 60 models)
> model[01][m01]=’model m01 of brand 1’;
> model[01][m02]=’model m02 of brand 1’;
> ...
> model[20][m59]=‘model m59 of brand 20’;
> model[20][m60]=‘model m60 of brand 20’;
>
> ARRAY ACCESSORIES (every models can to have n accessories; exmpl. m01-> 3
> accessories,
> m60 -> 2 access.)
> accessories[m01][]=‘accessories 1 of model m01’;
> accessories[m01][]=‘accessories 2 of model m01’;
> accessories[m01][]=‘accessories 3 of model m01’;
> ……..
> accessories[m60][]=‘accessories 1 of model m60’;
> accessories[m60][]=‘accessories 2 of model m60’;
>

Hi,

This is actually a JavaScript/JSON question.

What you probably need is something like this:
[Javascript]

for (var key in someArray){
var theValue = someArray[key];
// do stuff
}

which is a little like PHP's:

foreach ($someArray as $key => $theValue){

}

Whit that approach you'll have the key of some array, which you will
need in your accessories-array to look up the different values.

Regards,
Erwin Moller




--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: json_decode
Next Topic: Calling stored procedure on remote SQL Server machine with PDO
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 18:01:11 GMT 2024

Total time taken to generate the page: 0.02878 seconds