Help with JS

Access ChronoForms database read results in JavaScript.

Overview

The user attempted to use a CF variable directly in a JavaScript alert without proper syntax.
Enclose the CF variable within quotes in the JavaScript code to correctly output the data array.

Answered
ChronoForms v6
Cr Crams 02 Aug, 2018
Hi, I'm new to CFv6 and loving it, also the forum is great and I have been searching for this but just coulnd't find the answer, it's a really newbie's question, how do I access {var:data_readX} from the javascript block?
say for example I want to have an alert show the contents of the array data_read5, like this

alert({var:data_read5});

of course that doesn't work but you get the idea...
Gr GreyHead 02 Aug, 2018
Hi Crams,

It that is the value of a form variable then you can access it using the standard jQuery code jQuery('#some_id).value()

Bob
Cr Crams 02 Aug, 2018
Hi Bob! thanks for both your answers, I mean to access with js the data array from the DB read, any ideas?
Cr Crams 02 Aug, 2018
I mean, is there a way to do so? or should I just set up an ajax script? all I need is the array resulted from the DB read action...
Gr GreyHead 03 Aug, 2018
Answer
1 Likes
Hi Crams,

Sorry, I misunderstood, the standard shortcodes should work in the JavaScript action - your example is missing the quotes, please try with
alert('{var:data_read5}');
Bob
Cr Crams 03 Aug, 2018
Works like a charm🙂

Thanks Bob!!
This topic is locked and no more replies can be posted.