Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Revu Extreme Form JS Help  (Read 3865 times)

henleys16

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Revu Extreme Form JS Help
« on: February 19, 2018, 01:29:18 pm »

Hello everyone, I am pretty new to Extreme and nee to some help with JavaScript in my forms.
the code I am having troubles with is as follows:

if(this.getField("NameDropdown").value = "Name 1") {
this.getField("CostCode").value = "Code 1"
} else if(this.getField("NameDropdown").value = "Name 2") {
this.getField("CostCode").value = "Code 2"
}

The code is linked to a Mouse Up trigger on a button. The problem is that when I press the button, regardless of what name is selected in NameDropdown, it doesn't change the value of the CostCode textbox like I want it to, it instead changes whatever is selected in NameDropdown back to "Name 1".

Thanks in advance for anyone who can help me out.
Logged

Steve

  • Administrator
  • Sr. Member
  • *****
  • Karma: +5/-0
  • Posts: 353
    • RevuHelp
Re: Revu Extreme Form JS Help
« Reply #1 on: February 19, 2018, 02:10:51 pm »

See if this is any help.  I've also attached the working file from this example to this post so you can see / copy any code you might need.  There is a link to the file in the article as well.  While the tutorial is for Acrobat, the file works in Revu so you can see where the code goes in Revu, etc.

https://acrobatusers.com/tutorials/change_another_field

Hope that helps.  I am NOT a JS person by any stretch of the imagination.


Logged
Steve Jones
RevuHelp Forum Admin
steve@revuhelp.com
www.revuhelp.com
www.facebook.com/RevuHelp

ohcrocsle

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 4
Re: Revu Extreme Form JS Help
« Reply #2 on: March 15, 2018, 01:23:46 pm »

the boolean evaluation operator in JS is ==, so use that in your if conditions instead of =. right now, your if conditionals are setting the value of CostCode instead of checking it.

if(this.getField("NameDropdown").value == "Name 1") {
this.getField("CostCode").value = "Code 1"
} else if(this.getField("NameDropdown").value == "Name 2") {
this.getField("CostCode").value = "Code 2"
}
Logged

rader

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Re: Revu Extreme Form JS Help
« Reply #3 on: August 13, 2018, 03:50:52 pm »

I too was struggling with this recently. Not being a JS programmer either I have to thank Steve for putting together a site where the information I needed was.
That ComboTest_Complete really helped me understand what I needed to know regarding the variables and how they relate to the fields I was trying to use.

Simple thing, all I wanted was to create a RFI form using BlueBeam, have a selection of the Project Mangers listed via the Dropdown box and have it complete the signature section at the end of the RFI sheet.

Try as I might, I couldn't get the JS code to work with my fields and variables... until...
I removed the spaces in my Item List in the Dropdown Item List.

So I have a name of the PM as [John Smith] without the brackets and in the JS code when I was checking for "John Smith" it wouldn't work. I removed the space and used just the first name "John" and it's working now.  So either the name needs to have modifiers to check with the space in the name or maybe an underscore for the spacebar.

I'll try testing this further for my own satisfaction later. Right now with the first names it works and since I only have to worry about 6 PM's currently, its all good.
Logged