Stump the Panel: SharePoint Q&A

Immediate solutions for common SharePoint questions
It is currently Sun May 19, 2013 7:18 am

All times are UTC - 5 hours [ DST ]


Forum rules


What you are viewing is an archive of Stump the Panel. It remains for reference purposes. Please post all new questions on NothingButSharePoint.com
https://www.nothingbutsharepoint.com/sites/eusp/Forum



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 3:54 pm 
Offline

Joined: Wed Nov 03, 2010 3:30 pm
Posts: 6
Hello!

I am attempting to create a list that shows a colored date when an item is almost due or past due. With some research and some forum diving I stumbled upon some javascript to put in a CEWP. The code is a mix of Alexander Bautz inspired by Christophe@pathtosharepoint.

http://blog.pathtosharepoint.com/2008/1 ... nd-method/

Instead of returning a "traffic light" I was hopeing to return the "due date" colored in red or yellow depending on when it is due.

Code:
arr[i].innerHTML = "<DIV title='Due " + frendlyFieldDate + "' style='font-weight:bold; font-size:24px; color:yellow'>&bull;</DIV>";


Is there a way to put a variable (hopefully "frendlyFieldDate") where the "&bull" is? this way it would show the date in yellow instead of a yellow bullet?


Last edited by bbrtoluch on Wed Nov 03, 2010 4:42 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 4:30 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 12:35 pm
Posts: 364
Sure. You're really close:

Code:
arr[i].innerHTML = "<DIV title='Due " + frendlyFieldDate + "' style='font-weight:bold; font-size:24px; color:yellow'>" + frendlyFieldDate + "</DIV>";


Top
 Profile  
 
 Post subject: Re: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 4:48 pm 
Offline

Joined: Wed Nov 03, 2010 3:30 pm
Posts: 6
Great! Thanks! Works like a champ! I tried just about everything I could think of! But alas, the darn " " got me... so to use a variable you need:

Code:
"+variable+"


The only problem is... that you answered my question so fast im liable to post more!

V/r
Brian


Top
 Profile  
 
 Post subject: Re: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 4:55 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 12:35 pm
Posts: 364
Please do, Brian. That's what we're here for. :)

And to answer your question... yes, you're creating HTML within your string. Where you want a dynamic portion, you need to close the quotes, add your variable and then re-open the quotes, just like you did with the text for the title attribute. So, you're not really putting your variable inside quotes; you're putting it outside.


Last edited by jbhoward on Wed Nov 03, 2010 4:59 pm, edited 1 time in total.
Added clarification on the fix.


Top
 Profile  
 
 Post subject: Re: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 7:15 pm 
Offline

Joined: Wed Nov 03, 2010 3:30 pm
Posts: 6
I understand!!! Thanks again! Where is the donate button?

V/r
Brian


Top
 Profile  
 
 Post subject: Re: Calling Variable in HTML
PostPosted: Wed Nov 03, 2010 7:22 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 12:35 pm
Posts: 364
You can buy my eBook when it comes out next week. :) j/k


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group