Author Topic: Value prompt  (Read 2880 times)

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Value prompt
« on: 25 Mar 2008 03:27:35 am »
hi Friends,

i have value prompt on prompt page with following properties:

Select UI : List Box
Multi-Select : Yes
the value prompt contains static choices.

My query is , i need to select only one or two values from value prompt not more than that.( means the user can select upto two values not more than that.)

Please tell me how to solve this issue.

Thanks in advance....

Offline biejorrun

  • Senior Member
  • ****
  • Posts: 60
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #1 on: 25 Mar 2008 03:49:04 am »
You could create 2 single-select prompts, and combine them with an "OR"-operator.

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #2 on: 25 Mar 2008 04:42:57 am »
i think u did get the point what i have asked .

a value prompt contains 10 static choices. i can select at a time one or max two only not more than that.
If i use multi select property as yes i can select at a time one or two or three or all values . but in this case i should not select more than two.

i think this explanation may have given you still more in detial.

Thanks....

Offline biejorrun

  • Senior Member
  • ****
  • Posts: 60
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #3 on: 25 Mar 2008 05:03:06 am »
Well then, you're welcome!

Offline subhash

  • Full Member
  • ***
  • Posts: 17
  • Forum Citizenship: +0/-1
Re: Value prompt
« Reply #4 on: 26 Mar 2008 03:06:32 am »
hi,

 u can achieve this by keeping the select ui as check box.after keeping the select ui property as checkbox take a HTML item and write the java code within the loop. u can solve that.....

 ok.

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #5 on: 26 Mar 2008 03:25:51 am »
Thanks Subhash.

But can't we achive with list box.

if it works with check box , can u help me with java script (if u knew it). i don't know anything about java script.

Offline Sunchaser

  • Community Leader
  • *****
  • Posts: 155
  • Forum Citizenship: +2/-0
Re: Value prompt
« Reply #6 on: 28 Mar 2008 04:43:30 am »
Hello


I don't know if you have already solve your problem; If not, I post here a few lines of code, in order to try to help you.
This is not my favorite solution, but I don't have enough time to work on javascript to get what I was thinking of. Explanation: the code below creates a other 'Finish Button' to replace the default Finish button on the prompt page, and allow a check on the number of selected Items before running the report.
I would prefer to catch an event, like 'OnClick()' or 'OnChange()' or something like that on the listBox object, and I saw It is surely possible but I've never done this yet.
So, here's the code:
Code: [Select]
<!--owner-drawned button for prompting-->
<button type="button" name="finishAlert" id="finishAlert"
style="" class="clsPromptButton"
onmouseover="this.className = 'clsPromptButtonOver'"
onmouseout="this.className = 'clsPromptButton'"
onClick="mCheck()">Finish</button>

<!--function called on-click-->
<script text=javascript>
function mCheck()
{
var Lbox = document.forms["formWarpRequest"].elements["_oLstChoiceslstJS"];
var n_count = 0;
for (var i = 0; i < Lbox.length; i++)
{
if (Lbox[i].selected)
{
n_count++;
}
}
if (n_count > 2)
{
alert("Too much!!");
}
else
{
promptButtonFinish();
}
}
</script>

<!--insertion of button-->
<script xmlns:xIE5="http://developer.cognos.com/prompting/x IE5">
var promptButtonfinishCheckDate = new
CPromptButton (document.getElementById("finishAlert"),
PROMPTBUTTON_FINISH, true);
pageNavigationObserverArray pageNavigationObserverArray.concat('promptButtonfinishAlert');
notify();
</script>
. The property 'Name' of the listbox is 'lstJS' (for this example)
. "_oLstChoices" is a 'static value' in order to reach the good object type

Hope it will help,
++
 ;)

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #7 on: 28 Mar 2008 07:27:45 am »
Thanks..

Let me try it out.

Offline Sunchaser

  • Community Leader
  • *****
  • Posts: 155
  • Forum Citizenship: +2/-0
Re: Value prompt
« Reply #8 on: 28 Mar 2008 04:11:04 pm »
Hi,

As I've done in a subject of sir cognoise007, there is a way for catching some events of listbox.
Here is a short code, that should be put in a HTML Item after the listBox:
Code: [Select]
<script text=javascript>
var Lbox1 = document.forms["formWarpRequest"].elements["_oLstChoiceslstJS1"];
var attached = Lbox1.attachEvent("onchange", mCheck);
</script>

So, the little function 'mcheck()' described before should be stored in a another HTML Item. You will have to make some more checks because, if 'mcheck()' stay as it was described before, the report will be submitted as soon as a Item is selected in the listBox.

++
 ;)

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #9 on: 02 Apr 2008 06:53:35 am »
hi sunchaser,

It is not working.

Offline Sunchaser

  • Community Leader
  • *****
  • Posts: 155
  • Forum Citizenship: +2/-0
Re: Value prompt
« Reply #10 on: 02 Apr 2008 07:51:02 am »
Hi aamuktha,

So, I think you should tell more about what you have done  ;D
And what it is 'saying', what sort of error code ?

First, are you sure of the name of the Value prompt ? -> in the short code I posted, the name of this object is "lstJS1" (the last part of "_oLstChoiceslstJS1") and you should check that you change this point with the real name of your Value prompt (I think it has to be defined inevitably).

I will put this part:
Code: [Select]
<!--function called on-click-->
<script text=javascript>
function mCheck()
{
var Lbox = document.forms["formWarpRequest"].elements["_oLstChoiceslstJS"];
var n_count = 0;
for (var i = 0; i < Lbox.length; i++)
{
if (Lbox[i].selected)
{
n_count++;
}
}
if (n_count > 2)
{
alert("Too much!!");
}
else
{
promptButtonFinish();
}
}
</script>
in a other HMTL Item, put down at the beginning at the page; the short piece of code I posted at last should be in a separated HTML Item, put down after the Value prompt.

If my memory is good enough, I tried it and it was working (I'm going to check this anyway...)

Offline Sunchaser

  • Community Leader
  • *****
  • Posts: 155
  • Forum Citizenship: +2/-0
Re: Value prompt
« Reply #11 on: 02 Apr 2008 09:16:54 am »
Hi aamuktha,

I'm too stupid, in my last asnwers I forgot what you were asking at the beginning, so with the last idea the report will run as soon as an Item is selected in the list.
I apologize.  :-[

But I'm still thinking that the first 'technique' should work, there's no reason...

For the last idea, I'm actually trying to disable one of the 'standard' prompt-button ("Next" or "Finish") as soon as more than 2 Items (for example) are selected in the list, but It seems more difficult that I imagined first.
If anybody knows ...  ;)

++

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #12 on: 03 Apr 2008 06:58:02 am »
hi Sunchaser,

I have tried with the fisrt code by changing the list name as u said . but it is not working. still i am unable to select up to two values in value prompt.i am able to select only one value in value prompt.

Regards,
aamuktha

Offline Sunchaser

  • Community Leader
  • *****
  • Posts: 155
  • Forum Citizenship: +2/-0
Re: Value prompt
« Reply #13 on: 03 Apr 2008 07:40:56 am »
Hello,

Yes I know aamuktha, it was what I was trying to explain yesterday in my last message: I apologize, It was a mystake. The report will run in fact as soon as you select one Item in the listbox ... I answered too fast.

Instead of that, I was trying just to count the number of selected Items when a user click in the list (by catching the 'OnChange' event as I've done), and then to disable the 'Standard' buttons like 'Finish' or 'Next', in order to stop the user if more than two Items where selected.
But it was more difficult than I believed, and It is not working fine for the moment.

Just remember that the solution I gave on the 28 March (the one with the script for a 'owner-draw' FinishButton) is possible to use.

I will tell you if ever I succeed in what I'm trying now...

++

Offline aamuktha

  • Full Member
  • ***
  • Posts: 34
  • Forum Citizenship: +1/-0
Re: Value prompt
« Reply #14 on: 03 Apr 2008 10:55:57 pm »
Thanks a lot for your help.