I am trying to populate the array opid, with values that I gain access to in an each function. I have crudely tested the loop working using some alerts, the each statement is looping the elements I want. Now the problem is that I want access to the opid array after the each function as indicated below.
Can anyone help? Thanks Lee var opid = new Array(); $("a.btn.submit").click(function(){ // alert($(this).attr("id").substr(7)); var userid = $(this).attr("id").substr(4); $("#"+userid+" input:disabled").each(function(i){ // var opid = new Array(); if($("#chk_"+$(this).attr("id").substr(9)).is(":checked")) { if ($("#pa_"+$(this).attr("id").substr(9)).val() == '') { //display error, alert("If you have selected to submit a PO you must give it a weighting"); var error = 1; } else { alert($(this).attr("id").substr(9)+" "+$(this).val()+" "+$("#pa_"+ $(this).attr("id").substr(9)).val()) opid[i]['opid'] = $(this).attr("id").substr(9); alert(opid[i]['opid']); } } else { // alert("not selected"); } i++ }); ******************************************** Need access to opid array here ******************************************** });