0

これ以上先に進めないようです。私はプログラマーというよりグラフィック担当です。
ボタンが押されるたびに、白から灰色、赤、黒、白へと循環するボタンが必要です。これらのボタンは、1 つの PDF ファイルに 100 個以上含まれています。
これは私がこれまでに試したことです:

if (this.getField("Button1").fillColor = ["RGB",1,1,1])
  {
  app.alert({ cMsg: "Switch to Grey", });
  this.getField("Button1").fillColor = ["RGB",.5,.5,.5];
  };

if (this.getField("Button1").fillColor = ["RGB",.5,.5,.5])
  {
  app.alert({ cMsg: "Switch to Red", });
  this.getField("Button1").fillColor = ["RGB",1,0,0];
  };

if (this.getField("Button1").fillColor = ["RGB",1,0,0])
  {
  app.alert({ cMsg: "Switch to Black", });
  this.getField("Button1").fillColor = ["RGB",0,0,0];
  };

if (this.getField("Button1").fillColor = ["RGB",0,0,0])
  {
  app.alert({ cMsg: "Switch to White", });
  this.getField("Button1").fillColor = ["RGB",1,1,1];
  };

これは可能ですか?ありがとう

4

1 に答える 1

0

アップデート:

独自のコードを使用すると、次のようになります。

if (this.getField("Button1").fillColor == ["RGB",1,1,1])
 {
  app.alert({ cMsg: "Switch to Grey", });
  this.getField("Button1").fillColor = ["RGB",.5,.5,.5];
 }
else if (this.getField("Button1").fillColor == ["RGB",.5,.5,.5])
{
 app.alert({ cMsg: "Switch to Red", });
 this.getField("Button1").fillColor = ["RGB",1,0,0];
}
else if (this.getField("Button1").fillColor == ["RGB",1,0,0])
{
 app.alert({ cMsg: "Switch to Black", });
 this.getField("Button1").fillColor = ["RGB",0,0,0];
}
else if (this.getField("Button1").fillColor == ["RGB",0,0,0])
{
 app.alert({ cMsg: "Switch to White", });
 this.getField("Button1").fillColor = ["RGB",1,1,1];
}

以下の私の以前の回答:(参考としてのみ使用してください)

以下は純粋に JavaScript と HTML 用であり、PDF 用ではありませんが、それがどのように行われるかについての洞察が得られます。

JavaScript では、次のようにgetElementByIdand を使用できます。rgb

  document.getElementById("button1").style.backgroundColor == "rgb(0, 255, 0)"

ここで例を挙げます。次のような青色のボタンがあるとしましょう

<div>
<button id="button1" onclick="getcolor()" style="background-color:#0000FF; padding:5px;">Colored Button - Blue</button>
</div>

これを緑色に変更し、緑色の場合は青色に変更したいので、JavaScript は次のようになります。

function getcolor()
{
  var button_color = document.getElementById("button1").style.backgroundColor;
  if (button_color == "rgb(255, 255, 255)")
  {
    alert("Switch color to Grey");
    document.getElementById("button1").style.backgroundColor = "rgb(128, 128, 128)";
 }
 else if (button_color == "rgb(128, 128, 128)")
 {
    alert("Switch color to Red");
    document.getElementById("button1").style.backgroundColor = "rgb(255, 0, 0)";       
 }
 else if (button_color == "rgb(255, 0, 0)")
 {
     alert("Switch color to Black");
     document.getElementById("button1").style.backgroundColor = "rgb(0, 0, 0)";       
 }
 else if (button_color == "rgb(0, 0, 0)")
 {
     alert("Switch color to White");
     document.getElementById("button1").style.backgroundColor = "rgb(255, 255, 255)";       
 }
}

ちなみに、たとえば青色を比較するときは、rgb のスペースに注意してください。次のように、色の各 10 進値の後にスペースがない rgb(0,0,255) であってはなりません。

 if (button_color == "rgb(0,0,255)")

しかし、次のようにする必要があります。

 if (button_color == "rgb(0, 0, 255)")

更新されたデモを見る

于 2013-06-03T02:20:36.447 に答える