SpotOn Systems Blog by the Cognos Integration Experts!

Subscribe by Email

Your email:

Archived Blogs

Access archived "Where in my Cognos" and "Advanced Charting" blog posts. These posts are also available in "SpotOn the Cognos Edge" blog.

Your SpotOn the IBM Cognos Edge

Current Articles | RSS Feed RSS Feed

Setting the Value of a Text Box Prompt with Javascript in Cognos 8.4

Posted by Darren Nelson on Thu, Oct 15, 2009
  | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Hello again,

I've been working through a specific issue where I wanted to dynamically set the value of a Cognos 8.4 Text Box Prompt with Javascript. I immediately went to my previous blog posting to copy and paste the code! Unfortunately, this only got me half way.

Since the Cognos prompts aren't simply HTML form elements, it did not suffice to try searchPrompts("Address").value="HELLO!!!". What I REALLY needed to do was simulate the user typing the desired text. So, after spending some time trying to understand what is going on in the background, I'm pleased to announce that with just a few lines of Javascript, I can easily set the value!

<SCRIPT> function setTextBoxPromptValue(promptName, promptValue) { var SpotOnTargetControl = G_PM_THIS_.getControlByName(promptName); var SpotOnPCType=SpotOnTargetControl._type_; if(SpotOnPCType == "cognos.Prompt.Control.Text") { SpotOnTargetControl.bParse(promptValue,""); SpotOnTargetControl.setCurrentValue(); SpotOnTargetControl.checkData(); } } </SCRIPT> <A onclick='setTextBoxPromptValue("Address","520 Bronson Ave.")' href="#">Set Value for Address</A><BR>

Tags: , , , , ,

COMMENTS

Thank you very much. Your post help me very much.

posted @ Friday, January 15, 2010 1:45 AM by Setting the Value of a Text Box Prompt with Javascript in Cognos 8.4


Thank you for posting that script, its very helpful. 
 
Is it possible to write a similar script for a date prompt? 
 

posted @ Friday, February 19, 2010 8:07 PM by Andy


Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics