datacapture.cfg
Hi everyone
I have a problem in my datacapture.There are two select boxes named as Medium and Advertisment.Based on the Medium selected in the datacapture the Advertisement values will be populated in the Advertisement list box and saving the DCT...While I am editing the saved DCR, the value i had selected in the Advertisement field is not displayed..instead it is displaying the value above the selected value.
ie, let's say,The Medium list box consist of values such as medium1,medium2.. and if i select medium1 the corresponding value for Advertisement list box,say, advert1,advert2,advert3 will be populated..if i select medium1 and choose advert2 from Adverisement list and save the DCT,while opening the saved DCR, in the Advertisment list box it is displaying the advert1 as selected value instead of advert2...if i check the value for the advertisment it is diplaying the advert2 value only..suppose if i give an alert message anywhere in the "setAdvertisement function" and check for the advertisement value it is displying the correct value in the Advertisement list box..but when i remove the alert message, it is diplays the wrong value!!
IWEventRegistry.addFormHandler("onFormInit", init);
IWEventRegistry.addItemHandler("/userinformation/medium_name", "onItemChange",getAdvertvalues);
var Adv_values= "1##new;new##1;advert1##3;advert3##7;nokia|2##new;new##2;advert2##4;adtile4|3##new;new##6;testing##8;adtile|4##new;new##5;lights|5##new;new##9;sony";
function init()
{
var dcrname = IWDCRInfo.getDCRName();
if (dcrname != "")
{
var itemvalue = IWDatacapture.getItem("/userinformation/medium_name");
var medium_val = itemvalue.getOptions()[itemvalue.getValue()].value;
if (medium_val != "new")
{
//alert(medium_val);
setAdvertisement(medium_val)
}
else
{
var adv_options = new Array();
adv_options[0]=new Option("new","new",false,false);
IWDatacapture.getItem('/userinformation/advert_name').setOptions(adv_options);
}
}
}
function getAdvertvalues()
{
var itemvalue = IWDatacapture.getItem("/userinformation/medium_name");
if (itemvalue != null)
{
var medium_val = itemvalue.getOptions()[itemvalue.getValue()].value;
if (medium_val != "new")
{
setAdvertisement(medium_val)
}
else
{
var adv_options = new Array();
adv_options[0]=new Option("new","new",false,false);
IWDatacapture.getItem('/userinformation/advert_name').setOptions(adv_options);
}
}
}
function setAdvertisement(medium_val)
{
alert("setting......");
var adv_options = new Array();
var medium_split = new Array();
var adv_split = new Array();
var k=0;
var ans;
var item_value = IWDatacapture.getItem("/userinformation/advert_name");
var advert_value=null;
if (item_value.getValue()!= null)
{
advert_value = item_value.getOptions()[item_value.getValue()].value;
}
medium_split = Adv_values.split("|");
for (var i=0;i {
adv_split = medium_split.split("##");
if(medium_val == adv_split[0])
{
for (var j=1;j {
var adv_ans = new Array();
adv_ans = adv_split.split(";");
if (adv_ans[0] == advert_value)
{
adv_options=new Option(adv_ans[1],adv_ans[0],true,true);
ans=k;
}
else
{
adv_options=new Option(adv_ans[1],adv_ans[0],false,false);
}
k++;
}
break;
}
}
IWDatacapture.getItem('/userinformation/advert_name').setOptions(adv_options);
}