- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:27 PM - edited 12-18-2023 05:28 PM
Hello Everyone
I'm trying to create registration form. When the user selects student, it should show the student registration form. When the user selects instructor, it should show instructor registration form. I'm getting an error "onChange script error: ReferenceError: student is not defined function () { [native code] }". Not sure why if i miss anything. Or anything wrong with my script. Thanks for you help.
I wrote the client script on change:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:22 PM
Hi @huyjor ,
In this line
if (g_form.getValue('student_or_instructor') == student) {
Student should be under double/single qoutes else it will treat it as a variable.
Do something like this
if (g_form.getValue('student_or_instructor') == "student") {
It should work.
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:25 PM
@huyjor Please update your script as follows.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*
var selection = g_form.getSectionNames();
The alert comes back to me as student_registrationform
alert(selection);
*/
if (g_form.getValue('student_or_instructor') == 'student') {
g_form.setSectionDisplay('student_registrationform', true);
} else {
g_form.setSectionDisplay('student_registrationform', false);
}
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:28 PM
No need to use getValue , you can use newValue like below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*
var selection = g_form.getSectionNames();
The alert comes back to me as student_registrationform
alert(selection);
*/
if (newValue == 'student') {
g_form.setSectionDisplay('student_registrationform', true);
} else {
g_form.setSectionDisplay('student_registrationform', false);
}
}
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:46 PM
Hi @huyjor ,
If selecting student or instructor is it a choice field, if it is a choice field you can use a UI policy & UI Policy action @huyjor . without writing scripting you can fulfill the requirement @huyjor .
Let me know, how it works for you.
If my answer helps you in anyway please mark it as accepted solution or helpful @huyjor .
Thanks & Regards,
S. Lakshmikanth Gupta.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:22 PM
Hi @huyjor ,
In this line
if (g_form.getValue('student_or_instructor') == student) {
Student should be under double/single qoutes else it will treat it as a variable.
Do something like this
if (g_form.getValue('student_or_instructor') == "student") {
It should work.
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:25 PM
@huyjor Please update your script as follows.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*
var selection = g_form.getSectionNames();
The alert comes back to me as student_registrationform
alert(selection);
*/
if (g_form.getValue('student_or_instructor') == 'student') {
g_form.setSectionDisplay('student_registrationform', true);
} else {
g_form.setSectionDisplay('student_registrationform', false);
}
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:28 PM
No need to use getValue , you can use newValue like below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*
var selection = g_form.getSectionNames();
The alert comes back to me as student_registrationform
alert(selection);
*/
if (newValue == 'student') {
g_form.setSectionDisplay('student_registrationform', true);
} else {
g_form.setSectionDisplay('student_registrationform', false);
}
}
Regards,
Musab