Page 1 of 1

Adding via iframe

Posted: Tue Nov 12, 2019 9:22 pm
by GlenMcCabe
New to Nu builder and PHP. I am trying to develop a simple application with parent files and child files. I can display all the required child records in an iframe but when I try to add a new one I cannot work out how to get the parent record id into the foreign key field in the new record. I create records with 0 in the foreign key field.

Re: Adding via iframe

Posted: Wed Nov 13, 2019 12:20 am
by admin
GlenMcCabe,

Hopefully, this will help...

https://www.youtube.com/watch?v=fC4InxO ... ck&index=2


Steven

Re: Adding via iframe

Posted: Wed Nov 13, 2019 10:09 am
by GlenMcCabe
Thanks. Found this just before bedtime. About to give it a try.

Re: Adding via iframe

Posted: Wed Nov 13, 2019 5:13 pm
by GlenMcCabe
Unable to get this to work. I have a patient table with a main index patid. I have a referral table with many referrrals per patient and a field patientID to hold the relevant patid. I have an iframe which lists the referrals for the chosen patient. I have added this iframe on the main patient detail tab. Lists referrals for patient correctly. Also tried on a seperate tab and works properly. When I choose to edit an existing referral everything is fine. When I add a new referral I cannot automatically get the patid to populate the patientID. I can type in the patientID and this works fine.

I have tried the following pieces of JavaScript and a few variations of each. A value of 0 is added to patientID.

if(!nuMainForm() && nuFormType() == 'edit') {
nuHide('patientID');

if(nuIsNewRecord()) {

$('#patientID').val(parent.nuform.getcurrent().record_id).change();

}
}

-----------------------

if (nuFormType() == 'edit') {
// get value of patient id
var holdid = $("#patid", window.parent.document);
// assign the value to referral patientid
$("#patientID').val(holdid.val()).change();
}

Re: Adding via iframe

Posted: Wed Nov 13, 2019 6:13 pm
by kev1n
Hi,

JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.

Instead of:

Code: Select all

parent.nuform.getcurrent().record_id
Write:

Code: Select all

parent.nuFORM.getCurrent().record_id

Re: Adding via iframe

Posted: Mon Jan 27, 2020 4:10 pm
by joecocs
Hello,
kev1n wrote:

Code: Select all

if(!nuMainForm() && nuFormType() == 'edit') {
nuHide('patientID');

if(nuIsNewRecord()) {

$('#patientID').val(parent.nuform.getcurrent().record_id).change();

}
}
amazing it works for me.

Conversely, I would like to retrieve the value of $('#patientID').val to assign it to a record field $('#TmpID').val which is in the main form

if you have an idea for syntax !

Thank's