Quote:
Originally Posted by Jakez
How the hell would I pass an associative array to a javascript function?
Shitty example:
<a onclick="test(arr['item']='Item Name', arr['price']='4.95');">click</a>
function test(arr)
{
alert(arr['item'] + arr['price']);
}
|
why not do it like this instead
http://nation-x.com/test.html
Code:
<script type="text/javascript">
var arr = new Object();
function testIt() {
for (var i in arr) {
alert('arr[\''+i+'\'] is ' + arr[i])
}
}
</script>
If you click <a href="#" onClick="arr.item='Item Name'; arr.price='4.95';testIt(); return false;">this link</a> this script is executed:</p>