Page 1 of 1

Message when a Radio Button is selected

Posted: 14 May 2020
by TWendt
Hi all,

i need a script that popup a message when a radio button is selected.

my script does not work. Hmm, what is wrong.

fd.field('Absence_x0020_message').change(function(){
if(fd.field ('Absence_x0020_message').value().text() == "Deutsche Niederlassungen - E-Mails die nicht gelesen oder weitergeleitet werden"){
confirm('Please enter the E-Mail address from your info mailbox');
});

Can you help me?

Best wishes
Tom

Re: Message when a Radio Button is selected

Posted: 14 May 2020
by mnikitina
Hello Tom,

To get the text of the selected option you need to use this code:

Code: Select all

var index= fd.field('Choice').value();
fd.field('Choice').control()._el().find('td').eq(index).find('label').text();
So your code should look like this:

Code: Select all

fd.field('Absence_x0020_message').change(function(){
var index = fd.field ('Absence_x0020_message').value();
if(fd.field ('Absence_x0020_message').control()._el().find('td').eq(index).find('label').text() == "Deutsche Niederlassungen - E-Mails die nicht gelesen oder weitergeleitet werden"){
confirm('Please enter the E-Mail address from your info mailbox');
});

Re: Message when a Radio Button is selected

Posted: 14 May 2020
by TWendt
Hi Mnikitina,

many thanks for the fast answer but the script does not work. It works only when I add Value ('0') in line two.

fd.field('Absence_x0020_message').change(function(){
var index = fd.field ('Absence_x0020_message').value('0');
//if(fd.field ('Absence_x0020_message').control()._el().find('td').eq(index).find('label').value(); == "Deutsche Niederlassungen - E-Mails die nicht gelesen oder weitergeleitet werden"){
confirm('Bitte geben sie im Feld "Contact" entweder die E-Mail Adresse oder den Namen der Niederlassung ein');
});

What is wrong?
Best wishes
Tom

Re: Message when a Radio Button is selected

Posted: 15 May 2020
by TWendt
Update:

When I use the the script where in line two the value is changed, on every radio button the message is displayed.

Best wishes
Tom

Re: Message when a Radio Button is selected

Posted: 15 May 2020
by mnikitina
Hello Tom,

With this line, you are selecting the first option of the Radio Buttons field.

This is my typo, I'm sorry. There is an extra ; in the code.

Please try out this code:

Code: Select all

fd.field('Absence_x0020_message').change(function(){
	var index = fd.field ('Absence_x0020_message').value('0');
	if(fd.field ('Absence_x0020_message').control()._el().find('td').eq(index).find('label').value() == "Deutsche Niederlassungen - E-Mails die nicht gelesen oder weitergeleitet werden"){
		confirm('Bitte geben sie im Feld "Contact" entweder die E-Mail Adresse oder den Namen der Niederlassung ein');
	}
});

Re: Message when a Radio Button is selected

Posted: 15 May 2020
by TWendt
Hello mnikitina,

after I removed the 0 in line 2 the script works. Perfect.

Many thanks
Tom