nanami
October 12, 2020, 10:53am
1
I want to show textbox based on Checkboxgroup result.
The checkboxgroup can choose multiple selections.
But if select [the result], show the textBox2.
my code is
export function checkboxGroup1_change(event) {
if($w("#checkboxGroup1").value === 'the result') {
$w("#textBox2").show();
$w("#textBox2").expand();
}
}
This code not work.
Someone help me.
Try “the result”
And you don’t need to show / hide the text if you collapse/expand it.
And try to make a onClick event.
Maybe this is the error
nanami
October 12, 2020, 1:20pm
3
Hi Nick,
Thank you for your reply.
I try “the result” but, it doesn’t work.
And delete show / hide text, but it doesn’t work.
onClick event I tried but it doesn’t work.
Can you think of other solutions?
my code works fine used the radiobutton.
@nanami Take a look in your properties:
“Hidden on load” should be unchecked
“Collapsed on load” should be checked
If it doesn’t work, please send me your code again.
Okay, I found your problem.
You have to convert the value .toString() at first.
export function checkboxGroup1_change(event) {
if ($w("#checkboxGroup1").value.toString() === 'Football') {
$w("#textBox2").expand();
} else {
$w("#textBox2").collapse();
}
}
And I would use the else condition, to close the box again.
nanami
October 13, 2020, 9:35am
7
Hi Nick,
It works!
But the checkboxGroup can choose multiple selections.
Only checked ‘Football’, it works.
Checked ‘Football’ and ‘Baseball’, it doesn’t work…; ;
I want to Expand the “textBox2”, checked only ‘Football’
But I want to Expand the “textBox2” even checked ‘Football’ and ‘Baseball’.
What do you mean ?
“textBox2” schould expand, if ‘Football’ is checked.
“textBox2” should expand, if ‘Football’ and other checkboxes are checked ?
So if I have “Football” + “Baseball” + “Swimming”, “textBox2” should be expanded?
nanami
October 13, 2020, 11:28am
9
That’s right!
choose Football should be expand.
choose Football and Swimming should be expand.
choose Swimming and Baseball not expand.
include Football should be expand.
Yeah, the problem is, that the value is “Swimming, Football” if both are checked.
Can you use for “Football” a single checkbox ? Then you can use this code:
export function checkbox1_change(event) {
if ($w("#checkbox1").checked === true) {
$w("#textBox2").expand();
} else {
$w("#textBox2").collapse();
}
}
nanami
October 13, 2020, 12:39pm
11
@nickoertel No, I want use Checkboxgroup.
Because there need several answers.
For example.
The Question.
What is your favorite sports? Multiple answers are possible.
□Swimming
□Football
□Baseball
□Other
If the answer includes “other”, the text box expand.
in the database.
multiple answers in one cell.
Answer1 Football,Baseball
Answer2 Swimming,Other
※In the textbox comments is the other cell.
@nanami you can make the same, with single checkboxes, too. You can give every checkbox a value.
I’m sorry, but I don’t know a code for your checkboxGroup.
nanami
October 14, 2020, 12:34am
13
@nickoertel Thank you for your advice!
I know single checkbox and radiobutton code, so I try it.
But checkboxgroup type is different.
Someone, Please help me.
nanami
October 16, 2020, 5:01am
14
Does anyone have a different solution?