I have a radio button list of
'a' has value of 1, b=2, c=3, d=4, e=5
If 'a' is selected, I want its value of 1 to be assigned to X.
If 'b' is selected, I want its value of 2 to be assigned to X.
How do I code the above using
i) IF syntax
ii) the switch { case syntax?
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Iakov,
If syntax:
if (this.rawValue=='1') TextField1.rawValue="1";
if (this.rawValue=='2') TextField1.rawValue="2";
if (this.rawValue=='3') TextField1.rawValue="3";
if (this.rawValue=='4') TextField1.rawValue="4";
if (this.rawValue=='5') TextField1.rawValue="5";
Switch syntax:
switch (this.rawValue)
{
case '1' :
TextField1.rawValue="1";
break;
case '2' :
TextField1.rawValue="2";
break;
case '3' :
TextField1.rawValue="3";
break;
case '4' :
TextField1.rawValue="4";
break;
case '5' :
TextField1.rawValue="5";
break;
}
But the most elegant way to do it is :TextField1.rawValue=this.rawValue;
Yan.
Views
Replies
Total Likes
Hi Iakov,
If syntax:
if (this.rawValue=='1') TextField1.rawValue="1";
if (this.rawValue=='2') TextField1.rawValue="2";
if (this.rawValue=='3') TextField1.rawValue="3";
if (this.rawValue=='4') TextField1.rawValue="4";
if (this.rawValue=='5') TextField1.rawValue="5";
Switch syntax:
switch (this.rawValue)
{
case '1' :
TextField1.rawValue="1";
break;
case '2' :
TextField1.rawValue="2";
break;
case '3' :
TextField1.rawValue="3";
break;
case '4' :
TextField1.rawValue="4";
break;
case '5' :
TextField1.rawValue="5";
break;
}
But the most elegant way to do it is :TextField1.rawValue=this.rawValue;
Yan.
Views
Replies
Total Likes
> But the most elegant way to do it is :TextField1.rawValue=this.rawValue;
Hahahaha :-)
I had no idea. I thought one had to test for each radio button value, which was why I asked for IF and SWITCH syntax.
I tried your elegant suggestion and it worked elegantly.
Thank you!
Haha.
Views
Replies
Total Likes