Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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];
Copy link to clipboard
Copied
Yes, you can do it using 'rect' property
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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];
Copy link to clipboard
Copied
Great, thanks so much!
Copy link to clipboard
Copied
Hi Nesa, can I ask one more question? Your solution worked perecftly. My question is, if someone accidently clicked the Checkbox and then realize that their selection is wrong can they uncheck the Checkbox and have all the fields revert back to where they were before and or if they were hidden or visible at the beginning when they first opened the form. Once again thanks so much.
Copy link to clipboard
Copied
You can add something like this to the current script:
else if(event.target.value == "Off"){
this.getField("Text1").rect = [enter start position numbers here];
this.getField("Text1").display = display.hidden;}
change hidden to visible whichever you need.
If you need more help please post your full code you are using or even better post your file if you can.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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];
Copy link to clipboard
Copied
Thank you so much Nesa. It works perfectly.
Copy link to clipboard
Copied
Hello I just stumbled uppon this thread and i am doing something similar. Is it possible to move a text field for example 15 points below another one if a certain value of a combo box is set?
I tried this (thanks to GPT) it does nothing
if (event.willCommit) {
if (event.value == "1") {
var trial1 = this.getField("trial1");
var trial2 = this.getField("trial2");
// Ensure both fields are valid
if (trial1 && trial2) {
// Move trial2 15 points below trial1
trial2.moveTo(trial2.rect[0], trial1.rect[1] + 15, false);
}
}
}
Copy link to clipboard
Copied
Try this as custom calculation script of dropdown field (combobox):
var t1 = this.getField("trial1").rect;
var t2 = this.getField("trial2");
var t3 = t1[1]-t1[3];
if(event.value == "1")
t2.rect = [t1[0],t1[3]-15,t1[2],(t1[3]-15)-t3];
This will set the height and width of the trial2 field same as trial1.
Copy link to clipboard
Copied
It worked like a charm! You are awesome! Thank you š