- 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-20-2023 12:24 AM
@huyjor Glad you found solution, however there is no need to use g_form.getValue and instead use 'newValue' , try my solution as well.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 08:27 AM
The code for newValue is also working as well. Thanks