How can I make an invisible button that toggles an icon when clicked?


i extremely new acrobat , javascript whole, bit lost. working form demands make several toggle buttons based on images/formatting in existing pdf. javascript appropriate "invisible" button, without border or fill color, set icon in when clicked , remove icon when clicked again, ability toggle , forth endlessly? many thanks!

 

mark iii

there number of ways this. if want self contained within single button, can set button behavior of "push" , set mouse down icon non-blank icon , rollover blank icon. can place following code in mouse event of button:

 

// mouse script button

(function () {

 

     // reference button

    var f = event.target;

 

    // current submitname property

    var sn = f.submitname;

 

    // toggle submitname property

    f.submitname = sn === "" || sn === "false" ? "true" : "false";

 

    // set icon either down or rollover icon (blank) defined button

    var oicon = f.submitname === "true" ? f.buttongeticon(1) : f.buttongeticon(2);

    f.buttonseticon(oicon);

 

})();

 

 

this code co-opts little used submitname field property keep track of state of button. (this problem buttons, if form set submit "html", time property used.) retrieves either down icon or rollover icon use icon.

 

if don't how behaves, can use hidden companion button , set similarly, setting icon non-blank icon , down icon blank. code in button can like:

 

(function () {

 

    var f = event.target;

    var f2 = getfield("b2a");  // reference other button

    var sn = f.submitname;

    f.submitname = sn === "" || sn === "false" ? "true" : "false";

 

    var oicon = f.submitname === "true" ? f2.buttongeticon(0) : f2.buttongeticon(1);

    f.buttonseticon(oicon);

 

})();

 

 

this way don't have limit button behavior setting of push.



More discussions in PDF Forms


adobe

Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support