Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get result of a formula or Textbox

Hi guys,

simple problem:

How can I access the result of a formurla with JavaScript?

How can I get the content of a Textbox?  (The result of the formurla is in a Textbox)

I tried this three things:

1. I put the formula in a variable and read the variable in JavaScript-> gives me the formular but not the result

2. I tried to get the the content of the Textbox  -> no success (but works with Listboxes)

3. I tried to access the html directly with "document.getElementsByTagName("td")" and then get the value -> no success

can someone help me please?

11 Replies
datanibbler
Champion
Champion

Hi,

I have no idea concerning JavaScript - but you said it works with listboxes ((you can get the contents) - then why don't you just create a listbox (also in the "new object" menu) - I guess you don't even have to display it - and put the formula there, just like you did in the textbox - with that $() expansion syntax to get the result of the formula rather than its text.

HTH

Best regards,

DataNibbler

tresesco
MVP
MVP

I guess your first option should work. May be, there is a missing '=' in your variable definition. Try variable defition with a preceding '=' sign.

Not applicable
Author

yes that would work,

but I have more than one textbox and would have to create one listbox per textbox, so gets a little bit messy

I thinks this is not a fine solution

Not applicable
Author

i tried different things:

Nr 1 is working gives me the current User

Nr. 2 not working, after load script the variable is not avaiable, I don' t know why

Nr. 3 same as Nr.2

Nr. 4 give me only the string

Nr. 5 same as 4

so why is Nr. 1 working and Nr. 2 not?

tresesco
MVP
MVP

Rather try like:

Input:

Load * Inline [

Summand, Summand2

123, 1000

20, 100];

Tab1:

Load

          Sum(Summand) as SumA

resident Input;

Let LetFORMEL_1=Peek('SumA');

michael_anthony
Creator II
Creator II

If using vbscript macro's there is an evaluate function which will calculate the result of an input string such as your variable.  Presume same or similiar in javascript.

Not applicable
Author

thanks a lot this is working!

Edit:

Problem:

If I make a selection then the formurla is not calculated

tresesco
MVP
MVP

You have to define your variable in the front-end. Settings->Variable Overview. And there, the simple definition would be like:

=Sum(Summand)

Not applicable
Author

the problem is still there:

I want the value of the formula with current selection in the JavaScript-Extension