Forums

Help with JS

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...
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
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?
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...
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
Crams 03 Aug, 2018
Works like a charm🙂

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