Copy link to clipboard
Copied
Hi all,
Am curious to know if the follwoing is possible/plausible?.
I have a checkbox ("Crsdeferred1a") that when selected, transfers the user entered text value from another field ("Correctives1") to the field ("Correctives1copy"). The script in the "Correctives1copy" field to do this is thus;
if (getField("Crsdeferred1a").value=="DEF")
this.getField("Correctives1copy").value = this.getField("Correctives1").value;
De-selection of the checkbox ("Crsdeferred1a") leaves the text entered in the field, and is desired to be that way. Of course, if the user changes the text entered in the ("Correctives1") field, then re-selects the checkbox, it updates to the new text, which again is fine.
The 'twist' comes with this - is it possible to have a range of fields named "Correctives1copy", "Correctives2copy", "Correctives3copy" - that if the checkbox is re-selected, rather than update any value text-wise that is changed in field "Correctives1" - it then looks to see if any of these 3 fields are empty, and then transfers then entered text ("Correctives1") into an empty (i.e. available) field from the 3? ("Correctives1copy", "Correctives2copy", "Correctives3copy").
So, if i enter the text "deferred iaw 34-09-54A", select the checkbox, this transfers the text (with current script) to the "Correctives1copy" field. All good. If I now de-select the checkbox, re-enter the text, say "No longer an issue.", and then re-select the checkbox - rather than update the value in the field "Correctives1copy" - some script may be looks for the next empty field from the 3 "copy" fields, and enters the new text in to say "Correctives2copy", assuming that field is empty? or if filled previously, then to "Correctives3copy". These copy fields are set to "Read Only", no adjustment possible.
A bit unusual I'm sure, any advice greatly received.
Copy link to clipboard
Copied
As Mouse Up event of Checkbox use this:
if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives1copy").value == "")
this.getField("Correctives1copy").value = this.getField("Correctives1").value;
else if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives2copy").value == "")
this.getField("Correctives2copy").value = this.getField("Correctives1").value;
else if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives3copy").value == "")
this.getField("Correctives3copy").value = this.getField("Correctives1").value;
Copy link to clipboard
Copied
Try this script or have a look on the attached file and let me know if that is what did you expect.
if (event.target.value!="Off" && this.getField("Correctives1").value!="") {
for (var i=1; i<=4; i++) {
if (i==4) {
app.alert("All copy fields are full");
break;
} else if (!this.getField("Correctives"+i+"copy").value.length || this.getField("Correctives1").value==this.getField("Correctives"+i+"copy").value) {
this.getField("Correctives"+i+"copy").value=this.getField("Correctives1").value;
break;
}
}
}@+
Copy link to clipboard
Copied
As Mouse Up event of Checkbox use this:
if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives1copy").value == "")
this.getField("Correctives1copy").value = this.getField("Correctives1").value;
else if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives2copy").value == "")
this.getField("Correctives2copy").value = this.getField("Correctives1").value;
else if(this.getField("Crsdeferred1a").value=="DEF" && this.getField("Correctives3copy").value == "")
this.getField("Correctives3copy").value = this.getField("Correctives1").value;
Copy link to clipboard
Copied
Try this script or have a look on the attached file and let me know if that is what did you expect.
if (event.target.value!="Off" && this.getField("Correctives1").value!="") {
for (var i=1; i<=4; i++) {
if (i==4) {
app.alert("All copy fields are full");
break;
} else if (!this.getField("Correctives"+i+"copy").value.length || this.getField("Correctives1").value==this.getField("Correctives"+i+"copy").value) {
this.getField("Correctives"+i+"copy").value=this.getField("Correctives1").value;
break;
}
}
}@+
Copy link to clipboard
Copied
Hi Nesa/Bebarth,
Thankyou both so much for the responses, they both work admirably, so very grateful for your help in this! ;-).
Copy link to clipboard
Copied
What if he changes value if checkbox is still checked it will enter new value immediatelly or when all fields are full and checkbox is unchecked he will still get alert.
Copy link to clipboard
Copied
With my script you can't get twice the same text and you have a message when all fields are full.
@+
Copy link to clipboard
Copied
If all fields are full you get message all the time, you need to fix that.
Copy link to clipboard
Copied
@Asim123 script goes to checkbox not text field 🙂
Copy link to clipboard
Copied
Lol sorry about that @bebarth I thought script goes into calculation as OP had it in one.
Copy link to clipboard
Copied
Hi, I am using similar code as bebarth has given above;
if (event.target.value!="Off" && this.getField("Value1").value!="") {
for (var i=1; i<=4; i++) {
if (!this.getField("Value"+i+"copy").value.length || this.getField("Value1").value==this.getField("Value"+i+"copy").value) {
this.getField("Value"+i+"copy").value=this.getField("Value1").value;
break;
}
}}However, I am trying to pull numbers - not text. What am I doing wrong?
Copy link to clipboard
Copied
@bebarth if you have any idea?
Copy link to clipboard
Copied
In this part try add 'AsString':
"Value"+i+"copy").valueAsString.length
Copy link to clipboard
Copied
Thank you so much! Would you believe I tried AsString myself everywhere in the code - except for there... Appreciate it 🙂
Copy link to clipboard
Copied
Hi again,
How do I change this code so that it does as previously but even when values/text are the same? As in; I am using the code for inputting initials into a box and the code doesn't fill the boxes if the initials are the same e.g. LJ only fills once and not again for LJ
Copy link to clipboard
Copied
Hello Nesa, I'm hoping you can help as I am new to this.
I have a sheet where I simply want to add the EXT Price that populates from QYT x Price to the Text 3 box when the check Box is selected and be empty when you uncheck it.
The Ext Price function works but the check box is not.
I have entered code on the check Box mouse up fucntion but can't get it ti copy over and comes up NULL.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more