...

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



TinyScript
04-23-2009, 02: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()
count=0;
var strings;
function postCodeCheck() {
var ArrayElms = document.getElementById('userPostCode').value; /*.toUpperCase();*/
var readout = document.getElementById('readout')
items.push(ArrayElms)
for(i in items){ strings=items.join()}
count++;

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

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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum