Expand my Community achievements bar.

SOLVED

button that increments and one that clears

Avatar

Level 1

Hello, could anyone help me with a code for a button when clicked,  incremements by 1. I have a numeric field (not sure if it should be a  numeric or text field), and a button. I want when the user clicks the  button, the number in either the text or numeric field increments by 1. I  also need a code for another button, that when clicked, clears the text  field. I appreciate your help.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

To increment....

// form1.page1.subform1.incBtn::click - (JavaScript, client)

form1.page1.subform1.nf.rawValue = form1.page1.subform1.nf.rawValue + 1;

if (form1.page1.subform1.tf.isNull) {

  form1.page1.subform1.tf.rawValue = "0";

}

var numStr = form1.page1.subform1.tf.rawValue;

form1.page1.subform1.tf.rawValue = parseInt(numStr) + 1;

    
To clear....    
// form1.page1.subform1.clearBtn::click - (JavaScript, client)
form1.page1.subform1.nf.rawValue = null;
form1.page1.subform1.tf.rawValue = null;

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

To increment....

// form1.page1.subform1.incBtn::click - (JavaScript, client)

form1.page1.subform1.nf.rawValue = form1.page1.subform1.nf.rawValue + 1;

if (form1.page1.subform1.tf.isNull) {

  form1.page1.subform1.tf.rawValue = "0";

}

var numStr = form1.page1.subform1.tf.rawValue;

form1.page1.subform1.tf.rawValue = parseInt(numStr) + 1;

    
To clear....    
// form1.page1.subform1.clearBtn::click - (JavaScript, client)
form1.page1.subform1.nf.rawValue = null;
form1.page1.subform1.tf.rawValue = null;

Avatar

Level 1

Wow, that works awesome. Thanks for such a rapid response.


Avatar

Level 1

Thanks for the response, can a "clear" button be used to clear all the  fields to include a calendar and dropdown list? basically push one  button and all the fields become blank. I guess I could add each field  in the .rawValue=null, but there are too many to do that. I tried using  xfa.event.reset() but that did not work

Avatar

Level 1

Thanks for the response, can a "clear" button be used to clear all the

fields to include a calendar and dropdown list? basically push one button

and all the fields become blank. I guess I could add each field in the

.rawValue=null, but there are too many to do that. I tried using

xfa.event.reset() but that did not work

Avatar

Former Community Member

There is an object in the standard library called 'Reset Button'. It clears all form fields by issuing xfa.host.resetData().

Steve

Avatar

Level 1

Steve you always come through, thanks for always being so helpful.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----