简体   繁体   中英

Dynamics CRM 2011 Pass Array as Parameter

I have tried setting the parameter as:

array("item1","item2","item3")

and also as:

new array("item1","item2","item3")

and also as:

var Labels = new array("item1","item2","item3")

在此处输入图片说明

but I can't seem to pass an array to the following function:

function BoldLabel(Labels) {
  var length = Labels.length;
  var element = null;
  for (var i = 0; i < length; i++) {
    element = Labels[i];
    document.getElementById(element).style.fontWeight="bolder";
    document.getElementById(element).style.fontSize="13px";
  }
}

I keep getting an "array is undefined" error. I thought for sure I saw this done somewhere but can't find the example anymore. The problem is that I'd like to be able to reuse this code and so just passing an array of the items I want to bold would be easier than cutting and pasting the code to a new function and writing in each label name individually like

document.getElementById("new_pricingsubtotal_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal_c").style.fontSize="13px";
document.getElementById("new_pricingsubtotal1_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal1_c").style.fontSize="13px";
document.getElementById("new_lineitemtotal_c").style.fontWeight="bolder";
document.getElementById("new_lineitemtotal_c").style.fontSize="13px";
document.getElementById("new_trucktotalcost_c").style.fontWeight="bolder";
document.getElementById("new_trucktotalcost_c").style.fontSize="13px";

Any help with this would be greatly appreciated!!

Did you try Array (as opposed to array )? Also, you might try it using an array literal, eg: var myarray=["item1", "item2", "item3"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM