Home/Support/Support Forum/AWS- Can I change a button's value text?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

AWS- Can I change a button's value text?

0 votes
Can I change a button's value text to create an auto update ON/OFF toggle button? I also need this toggle button to make a call to RpSetRefreshTime() so that I can toggle web page updating either on or off.

I have not found a way to alter the buttons value text field from AWS. However, I can do it by using a javascript function and type="button". Problem is, AWS needs a type="SUBMIT" button in order to get a callback. When I use type="submit", my javascript onclick gets called twice for some reason which nullifies the toggle effect. It may not be possible to use javascript and a submit button callback at the same time?
asked Dec 22, 2015 in NET+OS by marzahld New to the Community (7 points)

Please log in or register to answer this question.

4 Answers

0 votes
I just added HTML as follows (not within an AWS tag or anything):
<INPUT name='ValsCopy12' type='button' value='1 >> 2' onclick='copyvals(1, 2);' >

You then get the text from the 'value' definition in the stub c file:
char ValsCopy12[] = "1 >> 2";

So by allocating a fixed amount of space, you can copy various messages into that area.

You can do a 'post' to submit the form from the Javascript if necessary
answered Jan 5, 2016 by steved2 Seasoned Professional (183 points)
0 votes
I finally figured out a way to do a toggle submit button that can toggle a C/C++ variable and change the buttons text. I could do this previously with just javascript, but it has no support for interfacing with the C interface code. One solution I've found is to use RpDynamicDisplay and just have dual buttons (one of which won't be shown when in the opposite mode)

<!-- RpDynamicDisplay RpItemCount=2 RpGetType=Function RpGetPtr=GetDevMode -->
<!-- RpItemGroup -->
<input type="submit" value="Enable Developer Mode">
<!-- RpLastItemInGroup -->

<!-- RpItemGroup -->
<input type="submit" value="Disable Developer Mode">
<!-- RpLastItemInGroup -->
<!-- RpLastItemInGroup -->

Then in your submit handler, just check for which button called submit:

char *whichSubmitButton;

// get the value on the submit button presses (all submit button presses come to this function)
whichSubmitButton = RpGetSubmitButtonValue(theTaskDataPtr);

if(strstr(whichSubmitButton,"Enable") != NULL) ...
answered May 6, 2016 by marzahld New to the Community (7 points)
edited May 6, 2016 by marzahld
0 votes
You can use RpFormNamedSubmit to dynamically change a button's text.

<!-- RpFormNamedSubmit RpGetType=Function RpGetPtr=GetDevMod RpSetType=Function RpSetPtr=SetDevMod -->
<input type=submit value="enable developer mode">
<!-- RpEnd -->

You can use the callback function to call RpSetRefreshTime
answered Nov 29, 2016 by cityvic New to the Community (2 points)
0 votes
citivic: I like the RpFormNamedSubmit method better, thanks for the comment. I'll have to change the code when I get back into this project.
answered Dec 2, 2016 by marzahld New to the Community (7 points)