Thanks Alexandra. One more problem with form (you don’t seem to have a specific area for the form on the forum)!
I am trying to send the form data to the server now, but am getting the following javascript error:
Error: elem.object is undefined
Source File: localhost/shopnet/codebase/dhtmlxform.js
Line: 1096
I cannot see anything wrong with the code below, but perhaps I am not interpeting the send structure properly?
var formData =
[
{type: "label", name: "voucherlbl", label: "Add New Voucher"},
{type: "input", name: "vouchernum", value:vouchNum, label: "Voucher Number"},
{type: "select", name: "vouchstaff", label: "Staff Member", connector: "voucherdetail.php?action=stafflist", validate:"selectedOpt"},
{type: "select", name: "vouchertype", value:vouchNum, label: "Voucher Type" ,connector: "voucherdetail.php?action=vouchertypes", validate:"selectedOpt"},
{type: "input", name: "voucherdate", value: getTheDate(), label: "Voucher Date", validate: "ValidDate"},
{type: "input", name: "voucheramt", value:"0.00", label: "Voucher Amount", validate: "ValidCurrency"},
{type: "input", name: "voucherrecp", value:"", label: "Voucher Recipient", validate: "NotEmpty"},
{type: "input", name: "vouchercomm", value:"", label: "Comments", rows: "5"},
{type: "button", name: "savevoucher", value : "Add New Voucher"}
];
var vouchForm = vouchLayout.cells("a").attachForm(formData);
vouchForm.attachEvent("onAfterValidate", function (id, result)
{
});
var myEvent = vouchForm.attachEvent("onButtonClick", function()
{
if (vouchForm.validate())
{
alert("sending");
vouchForm.send("voucherdetail.php?action=addvoucher", "post", function(xml)
{
alert("Voucher Added");
});
}
else
alert("Invalid entry, please check highlighted fields have been entered correctly");
});