给大家共享一些经常用到的一些crmForm窗体定制技巧和代码:
1. 改变lable的样式(加粗,变色,大小)
/*
change new_button field label style
*/
if (crmForm.all.new_button != null )
{
var field = crmForm.all.new_button_c;
field.style.fontWeight = ' bold ' ; // change font to bold
field.style.fontSize = ' 12px ' ; // change font size
field.style.color = ' #ff0000 ' ; // change font color
}
if (crmForm.all.new_button != null )
{
var field = crmForm.all.new_button_c;
field.style.fontWeight = ' bold ' ; // change font to bold
field.style.fontSize = ' 12px ' ; // change font size
field.style.color = ' #ff0000 ' ; // change font color
}
2. 把输入框替换成图片
/*
replace new_button_d to a button
*/
if (crmForm.all.new_button != null )
{
var field = crmForm.all.new_button_d;
var html = " <table border='0' cellspacing='0' cellpadding='0'><tr><img width='32' height='32' style='cursor:hand' src='/_imgs/ico_32_134.gif' alt='Click button' οnclick='Button_OnClick()' /></tr></table> " ;
field.innerHTML = html;
}
Button_OnClick = function ()
{
alert( " button clicked! " );
}
if (crmForm.all.new_button != null )
{
var field = crmForm.all.new_button_d;
var html = " <table border='0' cellspacing='0' cellpadding='0'><tr><img width='32' height='32' style='cursor:hand' src='/_imgs/ico_32_134.gif' alt='Click button' οnclick='Button_OnClick()' /></tr></table> " ;
field.innerHTML = html;
}
Button_OnClick = function ()
{
alert( " button clicked! " );
}
3. 把输入框替换成文本(使用replaceNode技术)
/*
replace new_button_d to a label
*/
if (crmForm.all.new_button != null )
{
var html = document.createElement( " <TD id='new_button_d'> " );
html.innerText = " this is a lable " ;
crmForm.all.new_button_d.replaceNode(buttonText);
}
if (crmForm.all.new_button != null )
{
var html = document.createElement( " <TD id='new_button_d'> " );
html.innerText = " this is a lable " ;
crmForm.all.new_button_d.replaceNode(buttonText);
}
4. 附加一个文本(无需新建attribute,直接用html绘出)
/*
append text under new_button
*/
if (crmForm.all.new_button != null )
{
var html = document.createElement( " <LABEL> " );
html.innerText = " this is a text field " ;
crmForm.all.new_button.parentNode.appendChild(html);
}
if (crmForm.all.new_button != null )
{
var html = document.createElement( " <LABEL> " );
html.innerText = " this is a text field " ;
crmForm.all.new_button.parentNode.appendChild(html);
}