0

Hi all, i'm working on a php script and i got a little javascript. i'm trying to get information from some hidden fields but i keep getting an error, udefined. here are the codes:

var counter = 5;
var avail = document.getElementById['available_array[counter][0]'].value;

here is the original

tmp=document.order.elements['available_array[counter][\"+document.order.elements['BRANCHC[ ]'].selectedIndex+\"]'].value;
here is the select
<SELECT NAME="BRANCHC[ ]" SIZE=1  ID = "BRANCH_LIST>
and here is the hidden tag:

<input type="hidden" id="available_array[<?=intval($temp)?>][<?=$j?>]" name="available_array[<?=intval($temp)?>][<?=$j?>]" value="<?=$available_array[$i][$j]?>">

please tell me what im doing wrong

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by madmital
0

I guess you cannot have the id and name of an html element an number value or array value.

Hi all, i'm working on a php script and i got a little javascript. i'm trying to get information from some hidden fields but i keep getting an error, udefined. here are the codes:

var counter = 5;
var avail = document.getElementById['available_array[counter][0]'].value;

here is the original

tmp=document.order.elements['available_array[counter][\"+document.order.elements['BRANCHC[ ]'].selectedIndex+\"]'].value;
here is the select
<SELECT NAME="BRANCHC[ ]" SIZE=1  ID = "BRANCH_LIST>
and here is the hidden tag:

<input type="hidden" id="available_array[<?=intval($temp)?>][<?=$j?>]" name="available_array[<?=intval($temp)?>][<?=$j?>]" value="<?=$available_array[$i][$j]?>">

please tell me what im doing wrong

0
var counter = 5;
var avail = document.getElementById['available_array[counter][0]'].value;

The second line of the above means:
Assign to variable named "avail" the value of the document element that has id "available_array[counter][0]".
I guess that's not what you want to do...I can't think of any case where naming an element "available_array[counter][0]" would be a good idea.
Maybe you mean something like this?:

var counter = 5;
var strIdOfElementToGet = available_array[counter][0];
var avail = document.getElementById(strIdOfElementToGet).value;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.