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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Handling '%' if entered in a (numeric) Text Box Prompt

Started by cogswell, 24 Feb 2011 01:56:12 PM

Previous topic - Next topic

cogswell

I have a text box prompt which I want to limit to numeric input. This can be done easily, but the associated parameter is actually used as a percentage.

In essence, I want Cognos to return '50' regardless of whether '50' or '50%' is entered. I can do a simple if-then-else logic to multiply paramvalue by 100 if it is less than 1, but a problem arises if the person chooses to enter '0.5%'...

Any ideas? Cognos 8.4 here.


CognosPaul

The problem here seems to be of a telepathic nature. The users must be trained in the correct way of using the system. It is not the developers job to build a system capable of mind reading or second guessing the user.

It may be difficult at first, but the choice has to be made: Either 0.5 = 50% or 0.5 = 0.5%. Having a system that will attempt to automatically convert the number will result in confusion and incorrect values being entered.

Sunchaser

Hi,

I would tend to agree with PaulM, and in the same time say that this approach - theoretically good - is not enough and cannot be applied "as is".
Yes, users have to be trained, informed, "educated", and if we can say coached.
But, you can rely on the fact that few lines of code correctly set up and tested will always have the same effect / behaviour, you can't rely on the fact that a human being correctly trained will always apply the good things; it is in the human being, a kind of fickle nature (I tried to find a correct translation for "versatile" from french).
With my very small experience, I can say that you should think of building a kind of "idiot proof" system ;-)
From my side, I check on database side if the data sent are correct before doing anything, and I check too on our custom prompt page what is entered.

melee

Ooh. I like these things. I'm going to be a renegade and offer another approach.

Consider the concept of an omnibox, something similar to Google's front page. From that text input, you can do a myriad of things - search, calculations, conversions, everything - you can take that same concept and apply it here.

Using a text input box, you can evaluate your user's input, validate, and process their request. And that's where it starts, simply.

Using Javascript, I'd approach this by attaching an event listener to a text input prompt. Every time that box changes, you should capture the data and run some logic against it; did the user type a % sign? If so, evaluate their input as .05. If not, evaluate it as-is. Did they put a text character in there? They probably didn't mean to, so you can remove it.

You could even hook this logic into the 'Finish' button on the page to change the input box data so it passes to your database correctly. There's a lot of very simple approaches here that will help your users out more.