Help with some jquery basics
Hi,
I'm new to these forums and jquery, so hello all!
I have this code below that iterates through a bunch of elements for every click. This works well and it iterates the correct elements ( i can see this via an alert that pops up the values i'm after). The problem is that I cannot figure out how to declare the variable `opid` so that I can have access to it below the each statement as shown in the code below.
Thanks for any help you can offer!
-
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){
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); // here I am populating the array i want later
// alert(theopid[i]['opid']);
}
}
else
{
// alert("not selected");
}
i++
});
*******************************
need access to the opid array here (after the each function that should populate it)
********************************
});