You are here: Re: how insert an array double in hidden field and use in javascript « All PHP « IT news, forums, messages
Re: how insert an array double in hidden field and use in javascript

Posted by Dennis de Wit on 08/30/06 10:50

artev wrote:
> this work (I see 10000)
> code php
> $fruits=10000;
> echo <input type="hidden" name="x1[]" id="x1[]" value="$fruits" >;
>
> code javascript
> var test3 = document.formID.elements['x1[]'];
> alert(test3[0].value);
> ---------------------------------------------------
>
> now the code bottom, not work; I see in the alert popup the word: array;
> I want to use the array of array in the javascript's code
> using the hidden's variable
>
> code php
> foreach ($arrayquery as $a)
> {
> $fruits = array($a['type'] => array(1 => 'color', 2 => 'pos'));
> echo <input type="hidden" name="x1[]" id="x1[]" value="$fruits" >;
> }
>
> code javascript
> var test3 = document.formID.elements['x1[]'];
> alert(test3[0].value);
>
> any idea?

All elements in your form have the same name and same ID. If you request
the elements by javascript you'll retrieve an array of all elements with
that name. You might want to change the id or name to unique entries for
each element.

That would do the trick.

Dennis

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация