Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Update Text Item based on Value in Text Box Propmt

Status
Not open for further replies.

qberta01

Programmer
Nov 14, 2005
113
0
0
Hello,

I am using BI 8.3 and would like to have a page that prompts the user for a value (Text Box Prompt) and once the value is entered I want to update a Text Item to reflect the entered value +1. So if the user enters a start range of say 1, I want the Text Item to dynamically reflect 2 as the end range. I found some code on Cognos support that updates a text box based on a change in a value prompt. I am having a difficult time manipulating the code to do what I want. Below is that Javascript from Cognos support:

<script type="text/javascript">
/**
Call this function to know if all required prompts have valid inputs.
*/
function canSubmPrompt()
{
var bFormValid = true;
var aPreProcess = getPreProcessControlArray();
if (aPreProcess)
{
var kCount = aPreProcess.length;
var k = 0;
for (k=0; k<kCount; k++)
{
var promptElement = eval(aPreProcess[k]);
if ( promptElement.isValid() === false )
{
bFormValid = false;
}
}
}

if (bFormValid === false)
{
var sPrompt_Required_Values_missing = "sPrompt_Required_Values_missing";
if (typeof PMT_UIM_PROMPT_CONFIRMATION_VALUE_MISSING == K_PRMT_sSTRING) {
sPrompt_Required_Values_missing = PMT_UIM_PROMPT_CONFIRMATION_VALUE_MISSING;
}
return false;
}

return true;
}

function getObject(obj, type)
{
// step through all child elements of obj and look for an id that starts with 'type':
for (var i = 0; i < obj.ownerDocument.formWarpRequest.elements.length; i ++)
{
if (obj.ownerDocument.formWarpRequest.elements !=null && obj.ownerDocument.formWarpRequest.elements.id != null)
{
if ( obj.ownerDocument.formWarpRequest.elements.id.indexOf(type) !=-1)
{
return obj.ownerDocument.formWarpRequest.elements.id;
}
}
}
}


function modifyListOnchange(targetTxt)
{
// mySelectDiv is a DIV that is added manually around the Value Prompt Drop Down List.
var myDiv = document.getElementById("mySelectDiv");
// the actual control is the firstChild object of the div.
var div = myDiv.firstChild;
// retrieve the Value Prompt Drop Down List object
var selectNode = getObject(div,"PRMT_SV_N");
// retrieve the List Options array
var mySelectNode = document.getElementById(selectNode);
// add an onchange event to the Value Prompt Drop Down List that will set the value of the Text Box to the same
// as the value in the Value Prompt Drop Down List, if the user changes the selection of the list box.
mySelectNode.onchange=function()
{
setTimeout('canSubmPrompt()', 100);
document.getElementById(targetTxt).value=this.value;
}
}

function validateEntry(txtVal)
{
var myDiv = document.getElementById("mySelectDiv");
var div = myDiv.firstChild;
var selectNode = getObject(div,"PRMT_SV_N");
var mySelectNode = document.getElementById(selectNode);

if (txtVal!='') {
for (i = 0; i < mySelectNode.options.length; i++)
{
if (mySelectNode.value == txtVal) {
mySelectNode.selected=true;
setTimeout('canSubmPrompt()', 100);
document.getElementById('validFlag').innerHTML ='<span style="font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #00FF33">OK</span>';
return true;
}
}
}
mySelectNode[0].selected=true;
setTimeout('canSubmPrompt()', 100);
document.getElementById('validFlag').innerHTML ='<span style="font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FF0000">X</span>';
return false;
}

window.onload=function(){
modifyListOnchange('txtEntry' );
}

</script>


I assume what I want to do is possible. Any help would be greatly appreciated.


thx

Q.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top