View Full Version : array question. need to display it's var name

04-23-2009, 03:22 AM
An array var only returns it's elements, but I'm wondering if there's a way display that string indentifier (I don't know what it would be called)along with the contents of the array.

here's my goal. where it says ... your array... I want it to write the name of the array. It's part of a javascript editor i'm attempting to create. This adds your text input in the text area as an element in an array when you double click. so, it would be nice to know which array you working on. Obviously, I'll know the name of it and I know there are plenty of ways to save the string as another variable and use that, so I't's not a matter of that. I was just wondering if I could get it to readout the associated name

<script type="text/javascript">
var items=new Array()
var strings;
function postCodeCheck() {
var ArrayElms = document.getElementById('userPostCode').value; /*.toUpperCase();*/
var readout = document.getElementById('readout')
for(i in items){ strings=items.join()}

readout.innerHTML=""+count+" elements in your array"+i-wanna-put-the-name-here+" ["+strings+"]"

<body >
<textarea id="userPostCode" ondblclick="postCodeCheck()">dblclick to add elms</textarea>

<div id="readout"></div>

rnd me
04-23-2009, 05:12 AM
i don't think you can, short of process of elimination.