The CreatorCon Call for Content is officially open! Get started here.

Alert message dependent on variable

CatalogCat
Tera Contributor

I would like to display an alert message on a catalog item, if a specific question choice in a Select box is chosen by the user. 

I have only been able to create a general alert to pop up OnLoad or OnSubmit, but can I make it trigger only if someone selects that particular question choice? 

function onSubmit() {
//Type appropriate comment here, and begin script below
alert("Text for alert message here.");
}

I am using Service Portal, version is London.

1 ACCEPTED SOLUTION

Mark Skinner
Mega Guru

Hi,

 

Just say you have a choice list called 'choice_list' and had the three options below: 

One

Two

Three

and you want an alert on option 'Two'

You could use the following 

 

function onChange() {
//Type appropriate comment here, and begin script below

var choice = g_form.getValue('choice_list')

if (choice == 'Two'){

    alert("Two has been selected.");
    
   }
}

 

If this has been helpful please mark as helpful, If this Answered your question please mark as Correct

View solution in original post

3 REPLIES 3

Mark Skinner
Mega Guru

Hi,

 

Just say you have a choice list called 'choice_list' and had the three options below: 

One

Two

Three

and you want an alert on option 'Two'

You could use the following 

 

function onChange() {
//Type appropriate comment here, and begin script below

var choice = g_form.getValue('choice_list')

if (choice == 'Two'){

    alert("Two has been selected.");
    
   }
}

 

If this has been helpful please mark as helpful, If this Answered your question please mark as Correct

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

You will need Onchange script on your choice field and code will be as below:

find_real_file.png

Script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

//Type appropriate comment here, and begin script below

if(newValue==''){
g_form.hideFieldMsg("employment_status");
}


if(newValue=="Permanent"){


alert("An employee who has been hired for a position without a pre-determined time limit.");
}

if(newValue=="Rolling contract employee (Non-US)"){

alert("This employee is an individual retained by Aspen for a predetermined time, for a predetermined price. This contract may be extended, depending on the business needs.");
}
if(newValue=="Internship"){

alert("This is a period of work experience offered by Aspen, usually lasting for a fixed, limited period of time. The individual has the opportunity to develop their understanding in a specific field or occupation.");
}

}

CatalogCat
Tera Contributor

Thanks guys, I have tested both of your options and they both work.