Home
Analytics
How to pass variable value from javascript function.
RahulD
Hi,<br />
<br />
I have one text block in my report where i have used the text block (control) with HTML exprrssion.<br />
<br />
From my one of the javascript function i want to set the Global Variable to str as shown below so that i can reuse it from my report with reportContext.getPersistentGlobalVariable("list");<br />
<br />
function list()<br />
{<br />
var str = "";<br />
var listbox = document.getElementById('PickList');<br />
for(var i=0;i<listbox.options.length;i++)<br />
{<br />
str += listbox.options
.text;<br />
if(i!=listbox.options.length-1) <br />
{<br />
str +=',';<br />
}<br />
<br />
}<br />
return str;<br />
<br />
}<br />
reportContext.setPersistentGlobalVariable("list", list);<br />
<br />
<br />
but javascript is not working.<br />
How do i should write my above expression in function? or outside?<br />
<br />
Regards,<br />
RahulD
Find more posts tagged with
Comments
RahulD
Hi,<br />
<br />
I have one text block in my report where i have used the text block (control) with HTML exprrssion.<br />
<br />
From my one of the javascript function i want to set the Global Variable to str as shown below so that i can reuse it from my report with reportContext.getPersistentGlobalVariable("list");<br />
<br />
function list()<br />
{<br />
var str = "";<br />
var listbox = document.getElementById('PickList');<br />
for(var i=0;i<listbox.options.length;i++)<br />
{<br />
str += listbox.options
.text;<br />
if(i!=listbox.options.length-1) <br />
{<br />
str +=',';<br />
}<br />
<br />
}<br />
return str;<br />
<br />
}<br />
reportContext.setPersistentGlobalVariable("list", list);<br />
<br />
<br />
but javascript is not working.<br />
How do i should write my above expression in function? or outside?<br />
<br />
Regards,<br />
RahulD
mwilliams
What do you mean by the javascript isn't working? The list isn't being created? Or the PGV isn't being set? Or both?
RahulD
Hi Michael,<br />
<br />
<br />
When i use reportContext object in javascript function it doesnot evaluate to anything. but, i use reportContext object outside javascript function again nothing happens.<br />
<br />
Actually i am trying to set global variable in javascript function (str value) and i am gonna use this value in DataSet::beforeOpen() as<br />
this.queryText = this.queryText + " ORDER BY " + reportContext.getPersistentGlobalVariable("list");<br />
<br />
Where i am going wrong?<br />
<br />
<br />
<script><br />
<br />
function list()<br />
{<br />
var str = "";<br />
var listbox = document.getElementById('PickList');<br />
for(var i=0;i<listbox.options.length;i++)<br />
{<br />
str += listbox.options
.text;<br />
if(i!=listbox.options.length-1) <br />
{<br />
str +=',';<br />
}<br />
<br />
}<br />
reportContext.setPersistentGlobalVariable("list", list);<br />
<br />
return str;<br />
<br />
}<br />
</script>
RahulD
Hi Michael,
The Problem is with setting PGV in javascript function.
Please help me out?
Thanks,
RahulD
mwilliams
I'm guessing the issue is that your html script tags aren't processed until "client side". The "server side" script methods in BIRT have already been called when this is processed, so the value would be set in the PGV too late. I could be wrong on this. I'll let you know if I find anything else out.