- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2019 12:50 AM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2019 12:56 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2019 12:56 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2019 01:04 AM
HI,
You will need Onchange script on your choice field and code will be as below:
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.");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2019 01:14 AM
Thanks guys, I have tested both of your options and they both work.