Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
nuPrompt() Insert into Field?
nuPrompt() Insert into Field?
Hello,
How can you use the nuPrompt function to enter the data entered into a field on the same form?
If nuPrompt is set to trigger on change of a Select object, Is it also possible so pressing the Cancel button undoes the change to the select field?
Thanks,
Paul
How can you use the nuPrompt function to enter the data entered into a field on the same form?
If nuPrompt is set to trigger on change of a Select object, Is it also possible so pressing the Cancel button undoes the change to the select field?
Thanks,
Paul
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: nuPrompt() Insert into Field?
Use the nuOnPromptClose callback to retrieve the entered value and assign it to a field.
Re: nuPrompt() Insert into Field?
The nuOnPromptClose shows how to set a nuMessage but been trying to use both nuSetValue and nuSetFormValue but neither seems to work
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: nuPrompt() Insert into Field?
nuSetFormValue() is a PHP function and can't be used in JavaScript.
nuSetValue() should work if you use the latest version to set the value of a select object.
To set the selected value (numberic)
To set a text value:
nuSetValue() should work if you use the latest version to set the value of a select object.
To set the selected value (numberic)
Code: Select all
nuSetValue('select_object_id', 123);
Code: Select all
nuSetValue('select_object_id', 'text value', 'text')
Re: nuPrompt() Insert into Field?
Thanks, have managed to get it working with this
Is there a way of undoing the change to the select object if the cancel button is pressed on the nuPrompt modal?
Code: Select all
function nuOnPromptClose(val, ok) {
if (ok) {
nuSetValue('mpd_reason',val)
}
}
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: nuPrompt() Insert into Field?
The idea was that if a user changed the Select value that nuPrompt would appear and ask, well demand, that they put a reason for that change in.
Select could be one of three values, so there is no default value to revert to, it would be the value last saved.
Would it be easier to disable the cancel button on nuPrompt, so if the user made a mistake they would just not save the whole record and exit?
Select could be one of three values, so there is no default value to revert to, it would be the value last saved.
Would it be easier to disable the cancel button on nuPrompt, so if the user made a mistake they would just not save the whole record and exit?
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: nuPrompt() Insert into Field?
Couldn't you store the current select value in a variable and when cancel is chosen in nuPrompt, revert to that stored value?
Re: nuPrompt() Insert into Field?
Ok, sounds good but not sure how to impliment that.
I've set an onclick to get the value of the Select object, and store it in a variable
I then tried to modify the nuPromptOnClose as follows:
But not quite working.
I've set an onclick to get the value of the Select object, and store it in a variable
Code: Select all
$status = nuGetValue('mpd_status',val);
Code: Select all
function nuOnPromptClose(val, ok) {
if (ok) {
nuSetValue('mpd_reason', val);
nuDisable('mpd_status')
}
else {nuSetValue('mpd_status', $status );}
}
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: nuPrompt() Insert into Field?
In the form's custom code:
and nuOnPromptClose():
Code: Select all
var status = nuGetValue('mpd_status');
and nuOnPromptClose():
Code: Select all
function nuOnPromptClose(val, ok) {
if (ok) {
nuSetValue('mpd_reason', val);
nuDisable('mpd_status')
} else {
nuSetValue('mpd_status', status);
}
}