Skip to main content
Participating Frequently
August 4, 2022
Question

How to make invisible button that turns into button with text and backround color

  • August 4, 2022
  • 2 replies
  • 1140 views

Hey!

 

I got image that have been printscreened. Image has "button" which I want turn in real button. This button should be as it is first and if pressed it should turn out same sized button with custom text and its own backround color. And if that button is pressed again it should be back at its "invisible button" state.

Also I want to that this button will make datefield under that button to show current time like "when did button were pressed". 

 

Please help and thank you beforehand!

 

-Jake

This topic has been closed for replies.

2 replies

Nesa Nurani
Community Expert
Community Expert
August 4, 2022

For "datefield" if thats actual field name use this:

this.getField("datefield").value = new Date();

 

For text, you want text in another button or text field and what is name of that field?

Participating Frequently
August 4, 2022

Thank you.

For the button I want that invisible button turns into green button with specific text on it. And if pressed again, it turns back as invisible button and also whips datefield empty. Recap: invisible button = nothing shows up, when pressed=> green button with text and current time datefield appears, when pressed again => invisible button and date vanishes

Nesa Nurani
Community Expert
Community Expert
August 4, 2022

Use this script:

if(color.equal(color.green, event.target.fillColor)){
event.target.fillColor = color.transparent;
event.target.buttonSetCaption("");
this.getField("datefield").value = "";}
else if(color.equal(color.transparent, event.target.fillColor)){
event.target.fillColor = color.green;
event.target.buttonSetCaption("Text goes here");
this.getField("datefield").value = new Date();}

 

Format 'datefield' to the date/time format you wish in 'datefield' properties → format tab.

Remove previous scripts from button field.

Participating Frequently
August 4, 2022

This is the JS now on my button and it works but I can't get it how to make the text to come over that and also how the current time on another datefield...

event.target.fillColor = (color.equal(color.transparent, event.target.fillColor)) ? color.green : color.transparent;