Re: how insert an array double in hidden field and use in javascript
- From: Dennis de Wit <newsgroups@xxxxxxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 13:42:27 +0200
artev wrote:
code phpAll 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.
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?
in my example
I have id=x1[] that is an array
the value that I insert in this array is an array;
so how I can see it?
so I really see the first array ?
var test3 = document.formID.elements['x1[]'];
alert(test3[0].value);
but if I write
alert(test3[0][0].value);
not work, why?
you have example of code? or how to correct that above?
I don't think your browser sees the name x1[] as an array item with the name x1, but more just an element with the name "x1[]". I think you should add indexes to your array in order to make this work. So the first element will be callex x1[0], the second x1[1], then x1[2]... etc...
Dennis
.
- References:
- Prev by Date: Re: how insert an array double in hidden field and use in javascript
- Next by Date: Re: why does this not work?
- Previous by thread: Re: how insert an array double in hidden field and use in javascript
- Index(es):
Relevant Pages
|