COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: yogeswari on 22 May 2013 05:40:30 AM

Title: Descriptions of javascript coding
Post by: yogeswari on 22 May 2013 05:40:30 AM
Hi,

The below sentence is the javascript code:

var theDiv = document.getElementById("menumber");
var node_list = theDiv.childNodes[0].getElementsByTagName("SELECT");
eleTg1Details = node_list[0].getElementsByTagName('OPTION');


I browsed and got infor like "getElementById" function retreives the Id of the element that we want to access and "getElemensByTagName" function retreives the Tagname of the element that we want to access.

What does ID and TagName means?Is it refers to Prompt ID and Name??If so how to set those properties in ReportStudio Cognos 10.1.

Moreover anyone give me full descriptions of the above 3 sentences.
Please help me.

thanks,
Yogeswari.
Title: Re: Descriptions of javascript coding
Post by: calson33 on 22 May 2013 09:39:53 AM
var theDiv = document.getElementById("menumber");

This is saying find the element on the page (an element is anything on a web page from textboxes to divs) with an ID of "menumber". Then put a pointer to that object into a variable called theDiv.

e.g. <div id="menumber">some text</div>

var node_list = theDiv.childNodes[0].getElementsByTagName("SELECT");

This finds all the elements within your object that are select boxes and puts a pointer into node_list. The childNodes[0] means look in the first set of nodes under thediv.


eleTg1Details = node_list[0].getElementsByTagName('OPTION');

This is getting the option list for the first select list found in the previous line.

If you are unfamiliar with select boxes and option lists then go here: http://www.w3schools.com/tags/tag_select.asp
Title: Re: Descriptions of javascript coding
Post by: yogeswari on 23 May 2013 01:30:32 AM
Hi Calson,

First of all, Thanks for your reply.
The coding which i have asked is used in convertion from lowercase to uppercase.  I am attaching the coding in the document.  Please go through the document and explain me clearly.  Since i am new to this, i would like to know from the scratch.

i could not understand what logic they used because the title is "Validating the user entered text to convert them to uppercase.  There is no such object "_textEditBoxpromptname".

Please help me out this.

Thanks,
Yogeswari.
Title: Re: Descriptions of javascript coding
Post by: calson33 on 23 May 2013 10:20:44 AM
All that routine is doing is going through the options in a select list, and checking each character to see if it is uppercase.

This seems odd to me, since option lists tend to be generated dynamically rather than with user input.

Also, there is no reference to "_textEditBoxpromptname" anywhere in that code, so if you are seeing that error, it is happening in another javascript function.
Title: Re: Descriptions of javascript coding
Post by: yogeswari on 24 May 2013 01:27:53 AM
Thanks for your reply.

Yes thats why i dont understand the logic used.  I know Javascript generally.
Since i am fresher to cognos i could not understand the cognos-javascript.

kindly provide one simple coding and explain me clearly pls.
I would like to learn it but could not understand it so only i am asking this :( :( :( :(.

Please help me.

Thanks,
Yogeswari.
Title: Re: Descriptions of javascript coding
Post by: calson33 on 24 May 2013 11:22:30 AM
Javascript is a very broad area. The best I can do is give you some links to help you get an intro into how it works:
http://www.w3schools.com/js/js_intro.asp
http://www.codecademy.com/courses/javascript-intro
http://www.adobe.com/devnet/html5/articles/intro-to-javascript-for-the-total-beginner.html