Jump to content

Problem with accessing/ defining multi level array variable


leruman

Recommended Posts

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;
        });

});

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.