leruman Posted April 7, 2012 Share Posted April 7, 2012 Greeting to eveyone. I am following this board for some time, have learned lot of good things. I am beginer in PHP/ java scrip. Code listed belov is part of larger file, i have included relevant files for this problem. I want to define multi level array in jscript file, and to be able to acces it from all functions. From my beginer level of knowldge this code and function shold work and allow this function to set value to variable attacks. Unfortunaltely it throws error: Uncaught TypeError: Cannot set property '0' of undefined like array is not deffiend at all. Can someone experienced tell me where i have made mistake and how to define muliti level array whch can be accesed from existing functions in file. Thanks in advance. var attack = new Array(new Array); $(document).ready(function(){ $('.seltarget').change(function() { // settig value data var player= $(this).nextAll('#player').val(); var pattack = $(this).nextAll('#pattack').val(); var target = $(this).val(); var party = $("#party").val(); $(this).next().val($(this).children('option:selected').text()); $.post('settarget.php',{ 'player':player,'pattack':pattack, 'target':target, 'party':party }); attack[player][pattack]=target; }); }); Quote Link to comment https://forums.phpfreaks.com/topic/260524-problem-with-accessing-defining-multi-level-array-variable/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.