Using Javascript URL in Calculated Columns

If you’re looking at using Javascript in a calculated column to call a URL, here’s a method that’s quick and simple to apply.

I found that when I attempted to run this inside a calculated column, the javascript url path removes the ” ” and therefore won’t run.

HTML Example of URL

<a onclick='javascript:openDialog("/server/site/CSSdocument.pdf");javascript:return false;' href="#" target=_self>

<img src="/server/site/CSS_Page_001.jpg" alt="" ></a>

So you could run the html inside a html file linked to the Content Editor Web Part first to make sure your Javascript works on the page, then add the Custom List with the calculated column below.


First, create two ‘single line of text’ columns, each containing the following text as default value




");javascript:return false;'

Then, I have two versions of syntax you can use. Make sure you change “The data type returned from this formula is:” to Number (1, 1.0, 100)  This will convert your column to html.

Calculated Column Version 1

="<a "&jscript1&""&FileName&""&jscript2&" href='#' title='Title' target='_self'><img src='"&Thumbnail&"' alt=''></a>"

Calculated Column Version 2

=CONCATENATE("<DIV><a ",jscript1,"",FileName,"",jscript2," href='#' title='book' target='_self'><img src='",Thumbnail,"' alt=''></a></DIV>")

So from the examples above, each “jscript” column will be replaced with it’s code and which will use the “FileName” column as it’s URL.

It’s not as Dynamic as I would like, so this would suit a Site Owner who familiar with Javascript.

Any questions if it doesn’t work and would like assistance, please comment below.


6 thoughts on “Using Javascript URL in Calculated Columns

  1. Brett July 25, 2013 / 7:14 pm

    Hey Sandy, Your code was stripped out of the comments.
    I haven’t had to use a button with onclick event in a calculated column before.
    What are you trying to run with the onclick button? Maybe I know of a work-around,

  2. sandy July 25, 2013 / 12:23 pm

    I’ve managed to insert a button in to my task list so far using the below code:


    I want to call the java script on button click is it possible? can you please help me


  3. Brett June 13, 2013 / 9:27 pm

    Hi Rebecca,
    I’m no expert in Calculated Columns, I have taught myself from trial and error and Googling what specifically I need answered. I’ll send you an email so you can send me your Calculated Column code and I can take a look if you like?

  4. Rebecca June 13, 2013 / 6:19 am

    I have a column that has a formula in it. I created a calculated column that copies the other column into the calculated field. However all it is doing is copying the formula and not actually doing the calculation. Do you think if I put the formula into separate columns and do a concatenate that that may work. Or do you have any other suggestions as to how I may get the column to actually do the calculations. I know the formula works because if I type it into the calculated column it does what is supposed to do. The reason I didn’t just type it into the calculated column is that each list item has a different formula. Any help is greatly appreciated.

  5. Brett June 7, 2013 / 8:32 am

    HI Andy, you can just add the call to the Title column in the HREF like this:


    This Post was actually for my own records but it’s good to see you get some use out of it.

  6. Andy June 7, 2013 / 1:59 am

    Great Article! Can we add the Title URL to the HREF? If so how?

Post a Comment

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s