If you are unable to create a new account, please email support@bspsoftware.com

 

Disabling and Enabling a Text Item using Java Script (Dimensional H.)

Started by gosoccer, 18 May 2014 06:06:12 PM

Previous topic - Next topic

gosoccer

Folks,

I'm trying to disable and enable a text item as a part of a Java Script routine within my Report Author 10.1.2.
The java script code is showing me is as a part of a regular HTML/Java Script outside of Cognos looks like the following,

Quotefunction disableTxt()
  {
  document.getElementById("myText").disabled=true;
  }
function undisableTxt()
  {
  document.getElementById("myText").disabled=false;
  }

I'm trying to do the same within Cognos Report Author but not sure about the steps to take. If someone
could help with this, I'll greatly appreciate it.

Thx so much in advance for your time.


rprameshwor

Its pretty much the same but the way you reference the text items is a bit different.

Set a name to the text Field. Under properties->Miscelaneous->Name
Lets say you name it "foo"

The below short JS code disables the text field.
With this you should be able to implement you own logic for disabling/enabling

<script>
fw=getFormWarpRequest();
fw._textEditBoxfoo.disabled=true;
</script>

FYI,
basic techniques for JavaScript Programming of Cognos Prompts:

https://www-304.ibm.com/support/docview.wss?uid=swg21376964

gosoccer

 :(WHOOOM@ I thought it would be simple.

I dropped an html item before the text item with the following after naming it foo under MISC,
<script>
fw=getFormWarpRequest();
fw._textEditBoxfoo.disabled=true;
</script>

It is not doing anything at all.
Is there a difference between textEdit Box and a text item?
Thank you in advance for your time
Kamran

navissar

What precisely does it mean, a text item that's disabled?
Typically, we disable or enable objects which can perform an action. Disabling them means they won't be able to perform that action.
Let's take a text box for example. It's a small white rectangle thingy which performs an action - it allows the user to write text in it. Disabling it means the user will not be able to write text in it.
Now, a text item is basically a text. It does nothing but sit there. It's a lot like a cushion, really. The user can't do much with them - they could, perhaps, if they feel so inclined, highlight it with their mouse, but that's just about it. A text on the screen has no interactive functionality. So, what does it mean to have it disabled? If there's no action, there's nothing to disable.
So, I think at this stage you probably need to clarify what the end result you are looking for is. What would you have the text item do?

gosoccer

Unfortunately Nimrod, the client wants to disable the simple text that exists on top of a Select List and a Search and Select list that you helped me in the past. I attached the screen for clarity.

So, the Select Single Site Below: needs to be disabled as the Select Box is grayed out. The bolded text is not part of the List Box.

Thx for your time.

navissar

Quote from: gosoccer on 20 May 2014 07:44:22 AM
Unfortunately Nimrod, the client wants to disable the simple text that exists on top of a Select List and a Search and Select list that you helped me in the past. I attached the screen for clarity.


I'm still none the wiser about what it means to have the text "disabled". Do you mean you want to make the text greyed out? you could have your script change the style of the text:
  document.getElementById("myText").style.color="#808080";

gosoccer

Now! Why didn't I think of this. This should work. I'll try it Nimrod.
Thank you for your time.