
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 07:55 AM
Hi all-
Trying to find a way, using a client script to get the previous value of a choice field before it is changed and without saving the form
Example:
User opens form
User has to select a value from 'Division' (CID, MDD, MED, ISB)
User selects CID
alert> ''
User then selects MDD
alert> 'CID'
User then selects ISB
alert> 'MDD'
I think this is doable via jquery but not 100% sure
Any help is greatly appreciated
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 09:22 AM
Using the g_scratchpad object may be better in this case. I've been trying to find a good article to reference but it's difficult now that the Wiki is gone.
Basically, you can use "g_scratchpad.variable_name = newValue" to keep the value updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 08:18 AM
Please share your code . Are you trying to use newValue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 08:48 AM
Try This:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
alert("The default value is " + oldValue);
alert("The New value is" + newValue);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 09:03 AM
HI Jamy,
Unfortunately oldValue/newValue won't work because oldValue is only what was saved to the DB. I want to get the old value w/out saving to the DB.
I did find a solution.
I created a hidden field called 'u_hidden_division'.
I populate this field w/ the value from Divisions.
So coming into the form, u_hidden_division is blank
If I change Division, I have an onChange client script that will take the value of u_division and populate u_hidden_division
If I change Division again, i can throw in an alert that will show me the value of the new value of u_division and the 'old' value stored in u_hidden_division.
I particularly don't like creating new fields, but this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 09:22 AM
Using the g_scratchpad object may be better in this case. I've been trying to find a good article to reference but it's difficult now that the Wiki is gone.
Basically, you can use "g_scratchpad.variable_name = newValue" to keep the value updated.