Page 2 of 3

Re: Browse screen

Posted: Fri Aug 02, 2013 8:28 am
by johan
Max,

I use my #browseTable# in a lookup on a subform (http://forums.nubuilder.cloud/viewtopic.p ... 931#p11931).
When I add your suggestion I always get message 'not available') and go back to the browsescreen of the form.
I think I have to add some JavaScript on my subform.

Johan

Re: Browse screen

Posted: Fri Aug 02, 2013 2:41 pm
by massiws
Johan, sorry but I made an error in my previous post: the code must be placed in Custom Code > Before Open (I correct it now).

Re: Browse screen

Posted: Fri Aug 02, 2013 4:28 pm
by johan
Max,

I've tried before open but this doesn't work. (or I do something wrong)
I don't open the form Books (go to editscreen). I only use the browsescreen of the form BOOKS to choose books in my lookup.

In that browsescreen (BOOKS) i have a column available / not available.
What I wan't is an alert when user selects a book that is not available.

Johan

Re: Browse screen

Posted: Sat Aug 03, 2013 9:52 am
by johan
Max,

I've created a function to check if the field in column actief = 2

Code: Select all

function checkfree(pthis){
PRE       = pthis.name.substring(0,13);

    if (Number(document.getElementById(PRE+'res_actief').value )= '2'){
    alert('Dit boek is niet beschikbaar in deze periode');
    }}
I want to run it when lookup is changed. When I put checkfree(this) in the all tab - onchange of the lookup nothing happens. Any idea how I can activate it when lookup is changed.
Thanks
Johan

Re: Browse screen

Posted: Sat Aug 03, 2013 6:01 pm
by massiws
Johan, have you tried to insert that function in Javascript field in Lookup tab?

Re: Browse screen

Posted: Mon Aug 05, 2013 7:54 am
by johan
Max,
I've tried several options but all of them giving errors.

Tried to just paste the code above (nothing happens),
refer to it with nuSreen.checkfree(this)
ScreenShot002.png
ScreenShot002.png (5.48 KiB) Viewed 10416 times
and edit the code to

Code: Select all

if (Number(nuGetRow('res_actief').value )= '2'){
  alert('Dit boek is niet beschikbaar in deze periode');
   }
With last code I get error
ScreenShot001.png
ScreenShot001.png (7.08 KiB) Viewed 10416 times
Any idea?

Johan

Re: Browse screen

Posted: Mon Aug 05, 2013 2:50 pm
by massiws
Johan, try this:

Code: Select all

var fieldID = nuGetRow() + res_actief;
if ( $('#'+fieldID).val() == '2') {
    alert('Dit boek is niet beschikbaar in deze periode');
};

Re: Browse screen

Posted: Mon Aug 05, 2013 3:47 pm
by johan
Max,

It works with this code:

Code: Select all

var fieldID = nuGetRow() + 'res_actief';
if ( $('#'+fieldID).val() == '2') {
    alert('Dit boek is niet beschikbaar in deze periode');
};
Thanks a lot for your help.
Johan

Re: Browse screen

Posted: Mon Aug 05, 2013 4:59 pm
by johan
Max,

Still have 1 question :oops:

Now I get the alert but if i click on ok of the alert the book is still selected.
How can I prevent to select that book in my lookup?

johan

Re: Browse screen

Posted: Mon Aug 05, 2013 6:19 pm
by massiws
Johan, add this after the alert():

Code: Select all

window.history.go(-1);
Max