On change doesn't work with "Specify your own value"
Hi,
I have a choice field that allows you to add your own value ("Specify your own value").
When this choice field changes a function is triggered that gets the value (used in a variable in the function). This works fine when choosing from the dropdown list. So if the:
- user selects ABC in 'MA'
- user selects 123 in 'ChoiceField'
= then 'MAcode' will be ABC123
But the function doesn't trigger when the user fills the field under "Specify your own value". So when the user does not use the dropdown list, but fills the "specify your own value" field, the function doesn't work:
- user selects ABC in 'MA'
- user writes 333 in "Specify your own value" in the 'ChoiceField'
= then 'MAcode' will be ABC but it should be ABC333
The choice field internal name is ChoiceField.
This is how my function is:
function setMAcode() {
var mText = fd.field('MA')control('getSelectedText');
var mNumber = fd.field('ChoiceField').value();
var combined = mText + mNumber;
fd.field('MAcode').value(combined);
}
fd.field('ChoiceField').change(setMAcode);
How can my function pick up the information from the "specify your own value" field?
I have a choice field that allows you to add your own value ("Specify your own value").
When this choice field changes a function is triggered that gets the value (used in a variable in the function). This works fine when choosing from the dropdown list. So if the:
- user selects ABC in 'MA'
- user selects 123 in 'ChoiceField'
= then 'MAcode' will be ABC123
But the function doesn't trigger when the user fills the field under "Specify your own value". So when the user does not use the dropdown list, but fills the "specify your own value" field, the function doesn't work:
- user selects ABC in 'MA'
- user writes 333 in "Specify your own value" in the 'ChoiceField'
= then 'MAcode' will be ABC but it should be ABC333
The choice field internal name is ChoiceField.
This is how my function is:
function setMAcode() {
var mText = fd.field('MA')control('getSelectedText');
var mNumber = fd.field('ChoiceField').value();
var combined = mText + mNumber;
fd.field('MAcode').value(combined);
}
fd.field('ChoiceField').change(setMAcode);
How can my function pick up the information from the "specify your own value" field?
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Oz!
You can detect change in the custom input with this code:
I also recommend switching this code:
to this:
It should work better.
You can detect change in the custom input with this code:
Code: Select all
fd.field('ChoiceField').control()._el().find('input').change(function(){
alert("Field changed!");
});
Code: Select all
fd.field('ChoiceField').change(setMAcode);
Code: Select all
fd.field('ChoiceField').change(function(){
setMAcode();
});
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Oz!
Try this code:
Try this code:
Code: Select all
fd.field('ChoiceField').control()._el().find('input[type=text]').val();
Cheers
Hi Nikita.
As you can see on the screenshot attached my variable isn't getting the XXX from the "specify your own value" field. My variable only gets [object Object]. This results in the field below not updating to "AFXXX", it is just "AFPending" as I chose from the dropdown menu.
I set the variable exactly like you mentioned, but it only gives me [object Object]:
var MAspecify = fd.field(''ChoiceField').control()._el().find('input[type=text]').val();
All assistance highly appreciated.
All the best.
As you can see on the screenshot attached my variable isn't getting the XXX from the "specify your own value" field. My variable only gets [object Object]. This results in the field below not updating to "AFXXX", it is just "AFPending" as I chose from the dropdown menu.
I set the variable exactly like you mentioned, but it only gives me [object Object]:
var MAspecify = fd.field(''ChoiceField').control()._el().find('input[type=text]').val();
All assistance highly appreciated.
All the best.
- Attachments
-
- SKU pic.jpg (20.42 KiB) Viewed 1653 times
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests