Page 2 of 3

Re: Browse screen

PostPosted: Fri Aug 02, 2013 3:58 pm
by johan
Max,

I use my #browseTable# in a lookup on a subform (viewtopic.php?f=6&t=8266&p=11931#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

PostPosted: Fri Aug 02, 2013 10:11 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

PostPosted: Fri Aug 02, 2013 11:58 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

PostPosted: Sat Aug 03, 2013 5:22 pm
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

PostPosted: Sun Aug 04, 2013 1:31 am
by massiws
Johan, have you tried to insert that function in Javascript field in Lookup tab?

Re: Browse screen

PostPosted: Mon Aug 05, 2013 3:24 pm
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 6039 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 6039 times


Any idea?

Johan

Re: Browse screen

PostPosted: Mon Aug 05, 2013 10:20 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

PostPosted: Mon Aug 05, 2013 11:17 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

PostPosted: Tue Aug 06, 2013 12:29 am
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

PostPosted: Tue Aug 06, 2013 1:49 am
by massiws
Johan, add this after the alert():
Code: Select all
window.history.go(-1);


Max