Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Headline or caption for browse window ?

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
honza1965
Posts: 20
Joined: Wed Apr 28, 2021 9:19 pm
Has thanked: 1 time
Been thanked: 1 time

Headline or caption for browse window ?

Unread post by honza1965 »

Have a nice day,
I need to add a caption to each window. Is there an easy way to solve it?
Thank you for your ideas, Honz
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Headline or caption for browse window ?

Unread post by kev1n »

Add this JavaScript in a form's custom code:

Code: Select all

function nuSetFormTitle(s, fs = 20){
   s = escape(s);
   $('#nuActionHolder').append("<span style='font-size:" + fs + "px; color:#54561d; vertical-align:middle;'>" + "&nbsp;".repeat(15) +  s + " </span>");
}

nuSetFormTitle('Hello nuBuilder ');

If you declare the above function nuSetFormTitle() under Setup -> Header, it can be used in any form.
honza1965
Posts: 20
Joined: Wed Apr 28, 2021 9:19 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Headline or caption for browse window ?

Unread post by honza1965 »

Amazing! ! ! Thank you very much :-)
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Headline or caption for browse window ?

Unread post by nathan »

Hello ,
I am new to nubuilder ,javascript and php so please be patient !!!
I will surely have more questions. :?:
I have tried this code in custom code of my form but the result is not what I expected ???
Also if I open in popup the text will not appear ??
Thank you

Code: Select all

function nuSetFormTitle(s, fs = 20){
   s = escape(s);
   $('#nuActionHolder').append("<span style='font-size:" + fs + "px; color:#54561d; vertical-align:middle;'>" + "&nbsp;".repeat(15) +  s + " </span>");
}
nuSetFormTitle('Hello nuBuilder '); 
This is what I get.
Hello%20nuBuilder%20
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: Headline or caption for browse window ?

Unread post by miasoft »

Try comment string :
//s=escape();
Wbr, miasoft.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Headline or caption for browse window ?

Unread post by kev1n »

The escape() function was missing:

Code: Select all

function escape(s) {
  var escaped = {
    '&': '&amp;',
    '<': '&lt;',
    '>': '&gt;',
    "'": '&#39;',
    '"': '&quot;'
  };
  return s.replace(/[&<>'"]/g, function (m) {
    return escaped[m];
  });
}
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Headline or caption for browse window ?

Unread post by nathan »

Thanks Kevin and miasoft both methods worked !!!
Post Reply