Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Can one assign a numerical value to a variable?

Avatar

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
lpianwi
Level 2

08-05-2013

Hi All,

Good afternoon,

I am currently working on a form that has strings as values in 2 different listboxes, and depending on what is selected a message pops up. Here is the script I wrote, but it does not seem to work right

var a=aKlaclistbox.raWvalue=="SSK";

var b=bZlaslistbox.raWvalue=="SGT";
a.value=1;
b.value=2;
if(a > b){
    xfa.host.messagebox("You cannot select a lower officer as the rating officer");

  }

It does not work, and I am just wondering if there is any way I can get around it so that I can compare the values. I need help from anyone on this forum.

Thanks

v/r

Tammy

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct Reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct Reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
Jono_Moore
Level 8

09-05-2013

There's probably a better way of doing this, as, depending on how many ranks you have, it could get cumbersome. Like using an array or something like that but not sure how to accomplish that.

If there are a lot of ranks to compare I think I'd suggest reworking things so that you can use the numeric value of the list box, it will be much easier in the long run.

As I mentioned above, I don't think the following is valid code:

var a=aKlaclistbox.raWvalue=="SSK";

Nor is (unless dealing with global variables):

a.value=1;

I think you need to do something like the following (hopefully someone else around here might have a better idea!):

var a;

var b;

if (aKlaclistbox.rawValue == "SSK") {

     a = 1;

}

if (bZlaslistbox.rawValue == "SGT") {

     b = 2;

}

//You would need a series of else/if with the above to map the different rank values.

if (a > b) {

   xfa.host.messagebox("You cannot select a lower officer as the rating officer");

}

Avatar

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
lpianwi
Level 2

Like

1 like

Total Posts

69 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
lpianwi
Level 2

09-05-2013

Good morning Jono, and thank you. Actually, SSK and SGT were values assigned to Sergeant, and Senior Sergeant in the list box using the Binding tab on the Object palette. So, on selection it displays SSK, and SGT, respectively. This makes the process difficult to make comparison. This is the simple reason why I am trying to see how I can use variables to assign values of 1, and 2 to the items. Hence, I have this code.

var a=aKlaclistbox.raWvalue=="SSK";

var b=bZlaslistbox.raWvalue=="SGT";

a.value=1;

b.value=2;

if (Klaclistbox.rawValue > Zlaslistbox.rawValue) {

   xfa.host.messagebox("You cannot select a lower officer as the rating officer");

}

Thanks, again

Avatar

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct Reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 10
Level 8
Jono_Moore
Level 8

Likes

111 likes

Total Posts

1,151 posts

Correct Reply

144 solutions
Top badges earned
Validate 10
Validate 1
Boost 50
Boost 5
Boost 3
View profile
Jono_Moore
Level 8

08-05-2013

You've got some coding errors and watch out for capitalization (rawValue not raWvalue).

The following won't work as far as I know but I'm not the best JavaScript programmer around:

var a=aKlaclistbox.raWvalue=="SSK";

var b=bZlaslistbox.raWvalue=="SGT";

"value" is only used for global variables, these would just be a = 1, etc.

a.value=1;

b.value=2;

I think for what you are trying to do I would assign values to the items in the list box using the Binding tab on the Object palette. SSK would equal 1, SGT would equal 2, etc.

Then you could do a compare of the two values:

if (Klaclistbox.rawValue > Zlaslistbox.rawValue) {

   xfa.host.messagebox("You cannot select a lower officer as the rating officer");

}