アップデート:
独自のコードを使用すると、次のようになります。
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 では、次のようにgetElementById
and を使用できます。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)")
更新されたデモを見る