Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

nubeforeSave or other function?

Locked
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

nubeforeSave or other function?

Unread post by johan »

Hi,

I'm looking for a sollution to check the things filled in on my subform.

When the user select p.ex. item with code '100' (whith the lookup) he also need to select item '110'

I want to get an alert before safe when item 100 is selected but item 110 is missing.

How to get it work?

Thanks

Johan
Attachments
subf.GIF
subf.GIF (19.94 KiB) Viewed 3501 times
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: nubeforeSave or other function?

Unread post by admin »

johan,

I haven't tested it but this should work for you..

Code: Select all


function nuBeforeSave(){

   if(hasValue('100') && !hasValue('110')){
      alert('110 needs to be added');
      return false;
   }else{
      return true;
   }


}

function hasValue(pCode){

   var sfName = 'thesubform';  //-- the subform name to look in
   var fdName = 'thefield';    //-- the field name to look in
   var ar     = Array();
   ar         = nuSubformRowArray('FMinvoice_item');
   
   for(var i = 0 ; i < ar.length ; i++){
      if(document.getElementById(ar[i] + fdname).value == pCode){
         return true;
      }
   }

   return false;
}   


Steven
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: nubeforeSave or other function?

Unread post by johan »

Steven,
You're great,

It works

Thanks a lot

Johan
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: nubeforeSave or other function?

Unread post by admin »

.
Locked