Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

nubeforeSave or other function?

Locked
johan
Posts: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

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
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2824
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

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: 422
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: nubeforeSave or other function?

Unread post by johan »

Steven,
You're great,

It works

Thanks a lot

Johan
admin
Site Admin
Posts: 2824
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: nubeforeSave or other function?

Unread post by admin »

.
Locked