Login / Register  search  syndication

          CRM Developer

Ryan Farley on CRM Development for SalesLogix, SageCRM, MSCRM, .NET - and all things geek

Changing Label Text at Runtime

Along the same lines as showing/hiding form fields and labels at runtime, it is often useful to change the text of field labels based on other events. This is an easy enough task which isn't really all that different than showing or hiding the label.

You just get a reference to the td cell containing the label, which we talked about before is named the same as the schema name ending in an '_c' suffix, and set the inner text for the cell. Here's a sample for a field with the schema name “new_myfield”.

crmForm.all.new_myfield_c.innerText = 'My New Label';

 

Make's it easy to change labels if needed to match things that are happening on the form. This could also be used to hide labels altogether as well.

What's This?
Bookmark and Share

About Ryan Farley

   Ryan Farley is the Director of Development for Customer FX Corporation and the creator of slxdeveloper.com.


Related Content
   Ping a Remote Server Using VBScript
At times you might build a customization in the SalesLogix LAN client that relies on networked resources.
Posted on May 19, 2008 by Ryan Farley to CRM Developer
 
   KnowledgeSync
Business Activity Monitoring (BAM) has become the way that many companies are generating real return from
Content from Partner Products Section
 
   ReadOnly and Disabled Fields
When you need to set fields disabled or readonly at runtime, you need to keep in mind the type of field y
Posted on Mar 06, 2006 by Ryan Farley to CRM Developer
 
   Working with CRM 3.0 Sample Chapter Available
Mike Snyder and Jim Steger of Sonoma Partners have announced the availability of the sample chaper on Wor
Posted on Feb 28, 2006 by Ryan Farley to CRM Developer
 
   Easier Navigation with Browser Tabs
A common complaint I hear those who are more used to the modality of Windows-based CRM applications is th
Posted on Feb 24, 2006 by Ryan Farley to CRM Developer
 
Comments

 

Kendall Reed said:

I'm kind of new to javascript, so this may seem like kind of an idiotic question. I put the following in my quote form onload:

var navExistingProducts;
navExistingProducts = document.all.navExistingProducts;
navExistingProducts.innerText = "Estimate Lines";

Which successfully changes the label on the nav bar, but at the same time I lose the icon. How would you change a nav bar label and preserve the icon?
May 10, 2006 8:48 AM
 

Ryan Farley said:

When you change the innerText of the navExistingProducts you are *replacing* what is there now. Part of what is there now is the img tag. You need to include the img tag in the text you are replacing.

ie:
navExistingProducts.innerText = "<img src='pathtoimage.jpg'> Estimate Lines";

See what I mean?

If you are unclear, add this line (before you set the innerText to "Estimate Lines") too see what is there now.

alert(navExistingProducts.innerText);

Then you can see the image tag that is currently in that element.
May 10, 2006 8:04 PM
 

M.Ergin SEYFE said:

Hello,
I add
alert(navExistingProducts.innerText);
but there is no image tag in the innerText.

Is there another way to add image to the navigation bar.

June 22, 2006 3:04 AM
 

Roman said:

Isn't it an unsupported customization? Changing HTML seems’ to be unsupported.
May 24, 2007 7:15 AM
 

Peter v A said:

This is NOT unsupported since you don't alter any CRM files. You just add Javascript code.
Offcourse theres no guarantee that it still works in the next version.
July 10, 2007 3:03 AM
 

selva said:

i have one text, one label and one button. am checking for text's mandatory. If its empty the label should display error text as "Field should not empty" i coded javascript as

function Button_Click()
{
if(document.getElementById("Text").value == "")
{
document.getElementById("Label").innerText ="Text Should not be empty";
document.getElementById("Text").focus();
}
}

i wrote this code and execute. the value assigned in label while debugging. but default value displayed coz page postback.
controls are asp.net controls.

Any one help to solve this issue welcome.
kindly
selva
chennai
December 27, 2007 7:58 AM
 

selva said:

hi all :)
i solved the problem.
while calling button_click() give reurn before function name.

<asp:button id="btn" OnClientClick="return button_click()"....
also give return false at end of function.

thanks :)
bye
December 27, 2007 8:25 AM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2009 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783
 Follow us on Twitter @CustomerFX






Login / Register