Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Getting the value of an select item
niranjan
hi,
In form api one can get the value of an item using IWItem.getValue() method but for select list it returns the index of the selected item. How can i get the value assigned to the value attribute of the select tag.
Also can i populate a select list based on certain criteria in a form api
Thanks
Niranjan
Find more posts tagged with
Comments
Migrateduser
Here is the sample code to get the value
var index = IWDatacapture.getItem("CD/ChannelORDealerCode").getValue();
var option = IWDatacapture.getItem("CD/ChannelORDealerCode").getOptions();
var value = option[index].value;
Hope this helps
rodigz
i can't make it work any idea? thanks
for ( var i=1; i <= constants.TOP_COUNTRY_MAX; i++ )
{
log.debug("topCountryIds = " + topCountryIds );
var countryItemAccessor = "/CATEGORY[" + i + "]/ID";
var topCountryItem = IWDatacapture.getItem(countryItemAccessor);
if ( ! mhrObject.isNull(topCountryItem) )
{
var countryId = topCountryItem.getValue();
log.debug("country id = " + countryId );
if ( topCountryIds.indexOf(countryId) > 0 )
{
alert("Each Top 5 Country selection must be different.");
valid = false;
log.debug("Invalid top countries");
break;
}
else
{
topCountryIds = topCountryIds + '-' + countryId;
//alert ("top:" + topCountryIds);
}
}
}
log.debug("End validing top countries");
}
jbonifaci
Krishna has told you that you need to get the index and the options array, then use the index to get the value from the options array. I don't see you trying to do this anywhere in your code? Maybe you should read his post again?
rodigz
i'm getting error null value.. any idea?
else if( dctType == constants.TOP_COUNTRY_TYPE )
{
var index = IWDatacapture.getItem("/CATEGORY/ID").getValue();
var option = IWDatacapture.getItem("/CATEGORY/ID").getOptions();
var value = option[index].value;
alert(value);
jbonifaci
Isn't CATEGORY a replicant? You need to supply the replicant number as well...
var index = IWDatacapture.getItem("/CATEGORY
[1]
/ID").getValue();
var option = IWDatacapture.getItem("/CATEGORY
[1]
/ID").getOptions();
var value = option[index].value;
alert(value);
Invoice.zip
INVIN0000202040SIM-L-C0.zip
rodigz
thanks.. i'm getting there.