Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Is it possible to use the status of a checkbox to change the fillcolor of a numeric field?

Avatar

Level 1

I have read through most all of the threads, but found none pertaining to my specific question.  I would like to change the fillcolor of a numeric field based upon the status (on/off) of a checkbox located on a different page.  In other words, if the checkbox is checked I want the numeric field to be yellow with a solid (thin) black border.  I have tried:

If (CheckBox1.rawValue="1")

{this.fillcolor="R,G,B";} else

{this.fillcolor="250,250,250"};

I haven't gotten the correct RGB values yet for the color I am using, that is why the script has "R,G,B"

I am pretty new at javascript and have been learning a lot from the forums, but I just can't seem to figure this one out.  Any help would be greatly appreciated.  Thanks

5 Replies

Avatar

Former Community Member

Give this a go...

// form1.page1.cb::click - (JavaScript, client)


if (this.rawValue == 1) {

  xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,0";

  form1.page1.nf.border.edge.color.value = "0,0,0";

}

else {

  xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,255";

  form1.page1.nf.border.edge.color.value = "255,255,255";

}

Don't forget to make your form a dynamic form.

Steve

Avatar

Level 1

Steve,

Thank you so much, that worked beautifully.  However, I have several rows of the numeric field spread over 31 columns (representing days of the month).  There are 31 checkboxes representing each day of the month.  My goal is to colorfill the entire colum of approximately 20 rows of numeric fields corresponding to the checked checkbox.  Is there an easier way to write the script to cover all numeric fields in the specific column representing the checked checkbox.  I guess I could duplicate the current script you provided 20 times for each numeric field, but if you had a better idea I would greatly appreciate it.  Thanks again for the quick response to my original question.  Oh yeah, is there a way to make the border a little thicker to match the linework already on the form (currently at a width of .001).

Avatar

Level 4

For the large number of fields that need this applied to them, assuming you have the checkboxes in a logical order like:

C1        C2         C3         C4         C5

day       day        day       day        day

day       day        day       day        day

day       day        day       day        day

day       day        day       day        day

So if they select C3 (checkbox 3), we get it's instanceIndex (2), then we can loop over the rows:

for(var i=0; i<numRows.length; i++){

       numRows[i].day[C3.instanceIndex].<Steve's code>

}

that would then do a column (that's psuedocode of course...I'm at work and can't write up a real example for you...but if I could I would!)

Hope that helps a little bit

Avatar

Level 1

AKloft,

Appreciate you taking the time to help me out during work.  I think I figured out an easier way to do it, but I can only get Steve's script to work on one of the numeric fields.  Is there a way to apply Steve's script to multiple numeric fields with the same name.  Example, I named the numeric field NF, and then duplicated the field.  This resulted in the fields to be named; NF[0], NF[1], NF[2], NF[3], etc.  Steve's script will only apply to NF[0].  I have tried writing the script using NF[*], but it doesnt work.  Do you know of a way to apply the script to all of the fields named NF?

Avatar

Level 4

You'd have to loop over all of them.  If you try doing a NF[*].fillColor, that will only set the first one I believe, so you'll have to do:

var totalNF = NF[*].length;

for(var i=0; i<totalNF; i++){

      NF[i].fillColor = blah blah blah

}