I am 1: listing all invoice records in my database.
2: checking the checkbox(s) of those invoices which I want to see details on.
3: traversing to the server PHP file using ?invid='checkbox value' of the particular invoice.
The problem I am having is that I keep getting an 'undefined error' re my form name.
The results of my getJSON call are roughly;
==================
Inv id 5
Inv No 807-A5
Vendor Home Depot
Date 2012-01-09
* Invoice Id (This is a check box) When checked - go to 'invoiceDetails.php' with value of this checkbox
==================
The above repeats for however invoices there are from the database.
Thanks in advance for help in solving this.
RP
The relevent code is contained in a.js file as follows: Again I can't get the damn file to upload.
Code: Select all
//GLOBALS
var i=0;
var j=0;
var table="";
var tableid="";
var category="";
var delFlag=false;
var revFlag=false;
var dataToProcess="";
var url="invoicesData.php";
// ==================================
$(document).ready(function() {
$("#rbox").hide();
window.getRadioClick=getRadioClick;
//window.nextRecord=nextRecord; // WITHOUT THIS NOTHING WORKS ????????
//window.previousRecord=previousRecord; // WISH I COULD FIND AN EXPLANATION FOR THIS !!
//window.setCategoryData=setCategoryData;
//window.reviseData=reviseData;
$("#what").show();
$("#what2").hide();
// ========= getRadioClick() ================
function getRadioClick() {
category=$('[name="category"]:checked').val();
//alert("category " + category);
if(category=="Invoices") {
table="invoice";
$.getJSON('invoicesData.php?tbl='+table, function(invData) {
var content="";
content= '<form name="pickInv">';
$(content).appendTo("#rbox");
$.each(invData, function(key, val) {
//console.log("id "+ val.invid +" inv no "+ val.invno+" vendor "+val.vendor);
content = '<p>' +'\tInv Id\t' + val.invid + '</p>';
content += '<p>' +'\tInv No.\t'+ val.invno+ '</p>';
content += '<p>' +'\tVendor\t'+ val.vendor+ '</p>';
content += '<p>' +'\tDate\t\t' + val.date+ '</p>';
content += '<br/>';
content += '<input type="checkbox" name="checkgroup" value=' + val.invid +'> Invoice Id.</input>';
$(content).appendTo("#rbox");
}); // each
content="</form>";
$(content).appendTo("#rbox");
$('#rbox').show();
for(i=0;i<document.pickInv.checkgroup.length; i++) { // ERROR pickInv not defined
if(document.pickInv.checkgroup[i].checked==true) {
alert("Checkbox for Invoice " + i + "is checked!" );
}
}
}); // getJSON
} // if category
} // get radio
}); // doc ready