Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use Data Item Values within a HTML-item with JavaScript

Status
Not open for further replies.

hzon

Programmer
May 29, 2009
2
NL
I have a Report (made in Report Studio), which contains a List and a HTML-item containing Javascript.
I have the following question:
Is there a way to access the “Data Item Values” from the List in the javascript? For example through XML?
 
Are you trying to pass the values to javascript? If so, you can wrap the list items with tags to get the contents. As a quick example, let's say you have a column like so:

[PRODUCT]
Apples
Bananas
Oranges

You can wrap the Data Item Values with Javascript to get their content into a Javascript array. It would look like this:

[PRODUCT]
<HTML Item>Apples<HTML Item>
<HTML Item>Bananas<HTML Item>
<HTML Item>Oranges<HTML Item>

The left side HTML Item would contain:

<script> myArray += "

And the right side HTML Item would contain:

,";</script>

This would create a comma delimited string which is read into Javascript. To turn it into an actually Javascript array you would need to have another HTML Item under the list which contained:

<script>myArray = myArray.split(",");</script>

Hope that helps





Gregory Brene
 
This helps verry much, thank you.

At the end of last week I found this kind of solution on a other forum. And that worked very wel.

In that case I created an extra column in the list containting a html-item. The text in the html-item was an other Data Item Value which contained a concatenated string which looked like:

<script language="javascript">getPosition("' +[Address line 1]+ '","' + [City]');</script>

In this case getPosition is a function (which is defined in another html-item) in which the parameters are the other Data Item Values in the list.

But I think your solution is better because in the getPostion function I am creating the array.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top