Radio button if statements
I've read quite a few comments on the forums here about radio button control (and have also visited the control site https://spform.com/javascript-framework ... eld-values)
However I'm struggling work out how to check the value of the radio button label.
I have a radio control (internal name 'IssueType') with 7 choices
Audit
Environment
internal etc etc
If I want to control other elements of the form from what has been choosen I used this:
function showHideFields(){
if (fd.field('IssueType').value() == 'Audit') {
$('.TAbleAudit').show();
}
else {
$('.TAbleAudit').hide();
}
}
//call the function on opening
showHideFields();
However, it doesn't work - Do I have to store the value as a variable and then use the variable within the if statement?
However I'm struggling work out how to check the value of the radio button label.
I have a radio control (internal name 'IssueType') with 7 choices
Audit
Environment
internal etc etc
If I want to control other elements of the form from what has been choosen I used this:
function showHideFields(){
if (fd.field('IssueType').value() == 'Audit') {
$('.TAbleAudit').show();
}
else {
$('.TAbleAudit').hide();
}
}
//call the function on opening
showHideFields();
However, it doesn't work - Do I have to store the value as a variable and then use the variable within the if statement?
I've got around this by using the index number (I had previous tried this, but without the "") so the code is as follows if it helps anyone:
function showHideFields(){
if (fd.field('IssueType').value() == "1") {
$('.TAbleAudit').show();
}
else{
$('.TAbleAudit').hide();
}
}
//call the function on opening
showHideFields();
function showHideFields(){
if (fd.field('IssueType').value() == "1") {
$('.TAbleAudit').show();
}
else{
$('.TAbleAudit').hide();
}
}
//call the function on opening
showHideFields();
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Roo,
Good job! I didn't even have time to answer the question, but yes, you are correct, by default Radio button choice returns number of the choice, instead of text. To get the text, you can use the following code, even though it's a bit lengthy:
Good job! I didn't even have time to answer the question, but yes, you are correct, by default Radio button choice returns number of the choice, instead of text. To get the text, you can use the following code, even though it's a bit lengthy:
Code: Select all
var issueTypeNum = fd.field('IssueType').value();
if (fd.field('IssueType').control()._el().find('td').eq(issueTypeNum).find('label').text() == 'Audit'){
}
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 21 guests