Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

How to apply different colors to different items in a list

Nuevo aquí ,
May 29, 2023 May 29, 2023

Dear community,

 

I've tried to find a solution on the forum but haven't found an answer. So, this time I need help creating a drop down list. I want this menu to have a list of 16 different RAL pallet colours that my customers will be able to select (only 1 of them) when filling out the offer form. I want to help them and make all these colours visible from the drop down list before and after they make their decision. What I mean is, is it possible to make it so that when the list of colours is expanded, each of them has "its" colour assigned to the background? And so that when you select it from the list, it appears as selected along with the assigned background colour.

 

At the moment I made short combo box with list of 3 colors (yellow - 1021 / red - 3020 / green - 6018) and I'm trying with:

"

switch(event.value)

{

case "1021":

event.target.fillColor = color.yellow;

break;

case "3020":

event.target.fillColor = color.red;

break;
case "6018":

event.target.fillColor = color.green;

break;

}"

 

 but it affects the color of the entire list, not a specific color selection, and it's not visible when selected.

 

 

TEMAS
Crear archivos PDF , Procedimiento , JavaScript , PDF , Formularios PDF
903
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
1 SOLUCIÓN ACEPTADA
Community Expert ,
May 29, 2023 May 29, 2023

Items in a list field cannot be different colors. 

However, individual fields could be put together to look like a dropdown list. Button fields would work best.

 

  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Ver la solución en mensaje original publicado

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 29, 2023 May 29, 2023

Items in a list field cannot be different colors. 

However, individual fields could be put together to look like a dropdown list. Button fields would work best.

 

  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
May 29, 2023 May 29, 2023
MÁS RECIENTES

Hi,

Here is a file with a script I did some times ago if that can help you.

RAL values come from wikipedia, I didn't check if they are all correct.

if (!event.willCommit) {
	if (event.changeEx!="0") {
		var couleur=event.changeEx.split(";");
		this.getField("theColor").value=couleur[0].toUpperCase();
		var laCouleur=["RGB",couleur[1]/255,couleur[2]/255,couleur[3]/255];
		this.getField("theColor").fillColor=["RGB",couleur[1]/255,couleur[2]/255,couleur[3]/255];
		var leNoir=color.convert(laCouleur, "G");
		if (leNoir[1]<.5) this.getField("theColor").textColor=color.white;
		else this.getField("theColor").textColor=color.black;
	} else {
		this.getField("theColor").value="";
		this.getField("theColor").fillColor=color.transparent;
	}
}

@+

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines