![]() |
Javascript experts?
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']); } |
I don't know of a syntax that will let you do it that way, maybe just pass it in as a string of key and value pairs and have your function build the array from them.
|
bump for J-S mags
|
Quote:
http://nation-x.com/test.html Code:
<script type="text/javascript"> |
Quote:
|
Fuck, if I run this more than once on a page then old arguments are still passed through, unless I re-define them, then it's all good, but if I'm not using one of them on the 2nd time it will still be there from the first one. I tried clearing everything each time the function is run but it still persists. Maybe I need to clear the object each time or something? Haven't tried that yet I gotta run somewhere real quick..
|
Code:
<a onclick="test({name:'Item Name', price:4.95});">click</a> |
Quote:
|
All times are GMT -7. The time now is 03:20 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc