if statement


hi,

 

i have if statement based on result of calculation.  if statement works if enter number manually won’t work result of calculation. can let me know why?

 

i have copied if statement below. text 2 calculation field.

 

if (this.getfield("text2").value=="18") {

event.value = "category 1"

      } else if (this.getfield("text2").value=="12") {

event.value = "category 1"

      } else if (this.getfield("text2").value=="11") {

event.value = "category 1"

      } else if (this.getfield("text2").value=="16") {

event.value = "category 3"

      } else if (this.getfield("text2").value=="10") {

event.value = "category 3"

      } else if (this.getfield("text2").value=="17") {

event.value = "category 2"

      } else { event.value = 0}

 

cheers

try using this.getfield("text2").valueasstring instead of .value , see if works properly


also, suggest using 'switch' command instead of multiple if/else if commands.

 

switch(this.getfield("text2").valueasstring) {
case '18':

case '12':

case '11':

  event.value = "category 1"

  break;

case '16':

case '10':

  event.value = "category 3"

  break;

case '17':

  event.value = "category 2"

  break;

default:
  event.value = 0

}



More discussions in PDF Forms


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support