Skip to main content
Participating Frequently
September 21, 2021
Answered

Can I move a Text Field to a different position on my form based on a Checkbox

  • September 21, 2021
  • 1 reply
  • 4092 views

Is there a way to MouseUp a Checkbox that will then physically move a text box to another position on my form? I know I can make Text fields visible and also hide them which I have been doing but I was hoping to I could use  Javascript as long as I know the position I want to move the Text field to on the form. Thanks in advance.

This topic has been closed for replies.
Correct answer Nesa Nurani

This is the form I have been working through Nesa. I have put a sticky note on the left hand side of the page.


Try this:

var fields = ["Paper.5140G","Paper.5120G","Paper.BannerS6G","Paper.CarbonS6G","Paper.5030G","Paper.VacS9G","Paper.5020G","Paper.VacKitS9G","Paper.BannerS9G"];
for(var i in fields){
this.getField(fields[i]).display = event.target.value != "Off" ? display.visible : display.hidden;}
this.getField("Paper.M2G").rect = event.target.value != "Off" ? this.getField("Paper.5140G").rect : [287.418,380.808,511.91,394.285];

1 reply

Nesa Nurani
Community Expert
Community Expert
September 21, 2021

Yes, you can do it using 'rect' property

Participating Frequently
September 21, 2021

Thanks Nesa, I am still new to Javascript. Could you give me a general idea what this would look like and where would I enter the script in the form?

Nesa Nurani
Community Expert
Community Expert
September 21, 2021

You need to enter 4 coordinates number in this order:
upper-left x, upper-left y, lower-right x, lower-right y.
Easiest way to find numbers is to set field where you want it to be and go to field properties->Position tab and write numbers down.
Take a look at the photo to see which number goes where.
Lets say you want to move field "Text1" to new position when checkbox is checked, you can do it like this:

Use script in checkbox as 'Mouse UP event:
if(event.target.value != "Off")
this.getField("Text1").rect = [285,761,380,738];