hi,
this is the code i am using in html layout painter.In the window_onload funcction( method UpdateData()
is given by the webfocus itself which is used to populate the dropdown boxes from data source.After the statement i am calling the windowOnload() function to default my dropdowns.I have placed alert() statement in between the UpdateData() and windowOnload() methods.If i am removing that alert statement i am getting the error.I think some delay should happen between UpdateData() function and windowOnload() function. For that delay if i am using for loop even then it is giving the errror.only if i use alert() stmt it's not giving the error. Please help me in this regard.
<script type=text/javascript>
var g_orglevel = !IBI.AMP.P_ORGLEVEL; ;
var g_orgnumber = !IBI.AMP.P_ORGNUMBER; ;
var g_dist = 0;
if(g_orglevel == 4)
{
g_dist = !IBI.AMP.P_DIST; ;
}
var g_expctrid=' ';
var g_expctrgrp=' ';
var g_period=' ';
var g_fiscalyear=' ';
var g_dropdnname=' ';
var g_dropdnvalue=' ';
function window_onload() {
UpdateData();
alert();
windowOnload();
}
/* This function generates the report in the iframes of the page based on the parameters
* from the sccr_user_access.fex file and disable the dropdowns required based on the
* parameters
*/
function windowOnload(){
/*Making the ExpenseCenter drop down defaulted to Total Store*/
for(var i = 0; i < document.getElementById["cboExpCtr").length; i++){
if((document.getElementById("cboExpCtr").options[i].value) == "Total Store"){
document.getElementById("cboExpCtr").options[i].selected = true;
g_expctrgrp = document.getElementById("cboExpCtr").options[i].value ;
break;
}
}
g_period = getMonthId(document.getElementById("cbomonth").value);
g_fiscalyear = getFiscalYear(document.getElementById("cbomonth").value);
if(g_orglevel == 0){
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'C';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_ACCT_GRP_FOC="+P_ACCT_GRP_FOC+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
else if(g_orglevel == 1){
//Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboRegion").length; i++){
if(document.getElementById("cboRegion").options[i].value == g_orgnumber){
document.getElementById("cboRegion").options[i].selected = true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'R';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src=cmd;
}
else if(g_orglevel == 2){
// Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboSpoke").length; i++){
if(document.getElementById("cboSpoke").options[i].value == g_orgnumber){
document.getElementById("cboSpoke").options[i].selected=true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'G';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
else if(g_orglevel == 3){
// Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboDistrict").length; i++){
if(document.getElementById("cboDistrict").options[i].value == g_orgnumber){
document.getElementById("cboDistrict").options[i].selected=true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'D';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
else if(g_orglevel == 4){
//If it is from store level we have to disable the other dropdowns except the District one
document.getElementById("cmdCompany").disabled = true;
document.getElementById("cboRegion").disabled = true;
document.getElementById("cboSpoke").disabled = true;
//* Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboStore").length; i++){
if(document.getElementById("cboStore").options[i].value == g_orgnumber){
document.getElementById("cboStore").options[i].selected = true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'S';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
}