Forum


13:28

17/06/2009

Hi all(Tony),
I found in documentation an example on CheckInvoice where you can do dynamic editing forms. However, I just can't figure out where this CheckInvoice function should be hooked with?
in editrules? How?
function CheckInvoice(formid) { var invno = 'invoice=' + $("#invoice",formid).val() ; if (invno == 'invoice=') { alert("invoice is blank; please enter account #") } else { $.getJSON(searchinvoice, invno, function(data) { if (data.status == 'No match found; please try again') { alert(data.status) } else { // Load the fields we know about $("#invoiced",formid).val(data.invoiced); $("#outstanding",formid).val(data.os); $("#acctname",formid).val(data.account); $("#project",formid).val(data.project); // Disabled loaded fields $("#acctname",formid).attr('disabled',true); $("#project",formid).attr('disabled',true); // Hide unneeded fields $("#tr_comment",formid).hide(); $("#tr_projectnumber",formid).hide(); $("#tr_shorttitle",formid).hide(); $("#tr_client",formid).hide();
Regards,
Burt
11:23

17/06/2009

Hi,
I have resolved the issue myself, but not sure whether it's the best.
In beforeShowForm event, we can do initialize the editing form.
for example hide certain fields:
$('#tr_spentTrigger', formId).hide();
$('#tr_freqTrigger', formId).hide();
and dynamicly hide/show fields:
$('#rewardType', formId).change(function(){
var index = $(this)[0].selectedIndex;
console.log("reward type selected" + ", selcted index: " + index);
if (index == 4) {
$('#tr_freqTrigger', formId).show();
$('#tr_spentTrigger', formId).hide();
}
else
if (index == 5) {
$('#tr_spentTrigger', formId).show();
$('#tr_freqTrigger', formId).hide();
}
else {
$('#tr_spentTrigger', formId).hide();
$('#tr_freqTrigger', formId).hide();
}
});
where formId is the edit form.
Burt
Most Users Ever Online: 715
Currently Online:
53 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66