turn a lookup filed to email clickable link

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
ushay
Veteran Member
Posts: 54
Joined: 2020-06-26 21:30

turn a lookup filed to email clickable link

Post by ushay » 2023-05-18 07:26

hello friend,

i have a lookup in my table to a filed that contains an email address, i have managed to format the value of the filed to an Emil Link and it is working inside the lookup:
emailLink.PNG
emailLink.PNG (20.3 KiB) Viewed 1780 times
is it possible to turn the text of the field outside to be clickable as well?
emailLink2.PNG
emailLink2.PNG (10.26 KiB) Viewed 1780 times
shay.

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1633
Joined: 2018-04-01 10:12

Re: turn a lookup filed to email clickable link

Post by pböttcher » 2023-05-18 08:00

Hi,

you can use javascript to change the text into a clickable text.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ushay
Veteran Member
Posts: 54
Joined: 2020-06-26 21:30

Re: turn a lookup filed to email clickable link

Post by ushay » 2023-05-18 09:06

OK, but where should i do it? in table-dv.js? can u please share an example?
thank you.

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1633
Joined: 2018-04-01 10:12

Re: turn a lookup filed to email clickable link

Post by pböttcher » 2023-05-18 14:21

Hi,
looking at the image you shared, yes, table-dv.js should work.

You may try something like

Code: Select all

$j('#FIELDNAME').wrap('<a id="FIELDNAME-mailto"><a>');
$j('#FIELDNAME-mailto').attr('href','mailto:'+$j('#FIELDNAME').text());
replace FIELDNAME with our valid fieldname
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ushay
Veteran Member
Posts: 54
Joined: 2020-06-26 21:30

Re: turn a lookup filed to email clickable link

Post by ushay » 2023-05-18 15:43

Thanks, i tried it with my field name 'email3':

Code: Select all

$j('#email3').wrap('<a id="email3-mailto"><a>');
$j('#email3-mailto').attr('href','mailto:'+$j('#email3').text());
i even tried this in table.php in table_dv():

Code: Select all

<script>
            $j(function() {
                var email = $j("#email3").text().trim();
                if (validateEmail(email)) {
                    var emailLink = $j("<a>").attr("href", "mailto:" + email).text(email);
                    $j("#email3").empty().append(emailLink);
                }
            });

            function validateEmail(email) {
                var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                return re.test(email);
            }
        </script>
but no luck.

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1633
Joined: 2018-04-01 10:12

Re: turn a lookup filed to email clickable link

Post by pböttcher » 2023-05-18 17:53

Is your field email3 readonly on the page?
Do you see any error in the develper console?

The code in the table_dv looks a bit strange.

I quickly set up a test with

Code: Select all

$j('#email3').wrap('<a id="email3-mailto"><a>');
$j('#email3-mailto').attr('href','mailto:'+$j('#email3').text());
and it works fine.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ushay
Veteran Member
Posts: 54
Joined: 2020-06-26 21:30

Re: turn a lookup filed to email clickable link

Post by ushay » 2023-05-18 18:47

hi,
it is a lookup field , not read-only.

when i add the code you suggested , the email address disappear
2023-05-18 212138.png
2023-05-18 212138.png (209.82 KiB) Viewed 1749 times
Attachments
2023-05-18 214436.png
2023-05-18 214436.png (12.13 KiB) Viewed 1749 times

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1633
Joined: 2018-04-01 10:12

Re: turn a lookup filed to email clickable link

Post by pböttcher » 2023-05-18 19:28

Hi,

well than it is a different story.

You may try

Code: Select all

setTimeout(change_mail,1000);

function change_mail () {
	$j('#email3').wrap('<a id="email3-mailto"><a>');
	$j('#email3-mailto').attr('href','mailto:'+$j('#email3').text())
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

ushay
Veteran Member
Posts: 54
Joined: 2020-06-26 21:30

Re: turn a lookup filed to email clickable link

Post by ushay » 2023-05-19 05:13

excellent :D
thank you very much, it works .

Post Reply