Message when a Radio Button is selected

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
TWendt
Posts: 109
Joined: Mon Sep 08, 2014

14 May 2020

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

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

14 May 2020

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');
});

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

14 May 2020

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

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

15 May 2020

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

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

15 May 2020

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');
	}
});

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

15 May 2020

Hello mnikitina,

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

Many thanks
Tom

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests