Om in één keer alle velden op een formulier op read-only te zetten (bijvoorbeeld na wijziging van een status), gebruik je onderstaand JavaScript:
for(var index = 0; index <>
if(crmForm.all[index].Disabled != null)
crmForm.all[index].Disabled = true;
Zoeken in deze blog
dinsdag 7 september 2010
Items uit een picklist hiden
Om items uit een picklist te hiden, gebruik je onderstaand JavaScript:
//Onzichtbaar maken picklist items
crmForm.all.CFPOrderstatus.DeleteOption(2);
crmForm.all.CFPOrderstatus.DeleteOption(5);
//Onzichtbaar maken picklist items
crmForm.all.CFPOrderstatus.DeleteOption(2);
crmForm.all.CFPOrderstatus.DeleteOption(5);
Opmaak vast telefoonnummer wanneer land = Nederland
//OPMAAK TELEFOONNUMER BIJ LAND = NEDERLAND
PhonenumberFormat = function()
{
if(crmForm.all.cov_landid_ba.DataValue != null)
{
LookupItem = crmForm.all.cov_landid_ba.DataValue;
if(LookupItem[0].name == 'Nederland')
{
var formFld = event.srcElement;var TelNo = "";
if(formFld.DataValue != null)
{
TelNo = formFld.DataValue.replace(/[^[0-9]/g, "");
}
else
{
return;
}
if(TelNo.substr(0,2) == "31")
{
var TelNo = "0" + TelNo.substr(2);
}
if(TelNo.substr(0,4) == "0031")
{
var TelNo = "0" + TelNo.substr(4);
}
if(TelNo.length > 9)
{
switch (TelNo.substr(0,3))
{
case "010":
case "013":
case "015":
case "020":
case "023":
case "024":
case "026":
case "030":
case "033":
case "035":
case "036":
case "038":
case "040":
case "043":
case "045":
case "046":
case "050":
case "053":
case "055":
case "058":
case "070":
case "071":
case "072":
case "073":
case "074":
case "075":
case "076":
case "077":
case "078":
case "079":
case "085":
case "088":
formFld.DataValue = "(+31)" + " " + TelNo.substr(1,2) + " " + TelNo.substr(3,3) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,2);
break;
default:formFld.DataValue = "(+31)" + " " + TelNo.substr(1,3) + " " + TelNo.substr(4,2) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,TelNo.length-8);
break;
}
}
}
}
}
PhonenumberFormat = function()
{
if(crmForm.all.cov_landid_ba.DataValue != null)
{
LookupItem = crmForm.all.cov_landid_ba.DataValue;
if(LookupItem[0].name == 'Nederland')
{
var formFld = event.srcElement;var TelNo = "";
if(formFld.DataValue != null)
{
TelNo = formFld.DataValue.replace(/[^[0-9]/g, "");
}
else
{
return;
}
if(TelNo.substr(0,2) == "31")
{
var TelNo = "0" + TelNo.substr(2);
}
if(TelNo.substr(0,4) == "0031")
{
var TelNo = "0" + TelNo.substr(4);
}
if(TelNo.length > 9)
{
switch (TelNo.substr(0,3))
{
case "010":
case "013":
case "015":
case "020":
case "023":
case "024":
case "026":
case "030":
case "033":
case "035":
case "036":
case "038":
case "040":
case "043":
case "045":
case "046":
case "050":
case "053":
case "055":
case "058":
case "070":
case "071":
case "072":
case "073":
case "074":
case "075":
case "076":
case "077":
case "078":
case "079":
case "085":
case "088":
formFld.DataValue = "(+31)" + " " + TelNo.substr(1,2) + " " + TelNo.substr(3,3) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,2);
break;
default:formFld.DataValue = "(+31)" + " " + TelNo.substr(1,3) + " " + TelNo.substr(4,2) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,TelNo.length-8);
break;
}
}
}
}
}
maandag 6 september 2010
Selectievakje (bit-veld) reageert niet op scripting
Wanneer je aan een selectievakje (bit-veld) een JavaScript koppelt, gaat het script niet af wanneer je het desbetreffende vinkje aan- of uitzet. Alleen door met tab het veld te verlaten, zal het script afgaan. Door onderstaand script te gebruiken in de OnLoad van het formulier, wordt dit gedrag afgevangen:
crmForm.all.cov_adverteerder.onclick = function()
{
crmForm.all.cov_adverteerder.FireOnChange();
}
crmForm.all.cov_adverteerder.onclick = function()
{
crmForm.all.cov_adverteerder.FireOnChange();
}
Veld in hoofdletters
if(crmForm.all.address1_city.DataValue != null)
{
crmForm.all.address1_city.DataValue = crmForm.all.address1_city.DataValue.toUpperCase();
}
{
crmForm.all.address1_city.DataValue = crmForm.all.address1_city.DataValue.toUpperCase();
}
Eigenschappen van een lookup field uitvragen
In onderstaand voorbeeld zie je hoe je de verschillende eigenschappen van een lookup field kunt uitvragen:
function HandleOnChangeLookup()
{
if(crmForm.all.primarycontactid.DataValue != null)
{
var lookupItem = new Array;
lookupItem = crmForm.all.primarycontactid.DataValue;
// The text value of the lookup.
alert(lookupItem[0].name);
// The GUID of the lookup.
alert(lookupItem[0].id);
// The entity type name.
alert(lookupItem[0].typename);
// The entity type code of the lookup: 1=account, 2= contact.
alert(lookupItem[0].type);
}
}
function HandleOnChangeLookup()
{
if(crmForm.all.primarycontactid.DataValue != null)
{
var lookupItem = new Array;
lookupItem = crmForm.all.primarycontactid.DataValue;
// The text value of the lookup.
alert(lookupItem[0].name);
// The GUID of the lookup.
alert(lookupItem[0].id);
// The entity type name.
alert(lookupItem[0].typename);
// The entity type code of the lookup: 1=account, 2= contact.
alert(lookupItem[0].type);
}
}
Abonneren op:
Posts (Atom)