function displaymessageNow()
{
var divArray = document.getElementsByClassName("productitemcell");
for (var i = 0; i<divArray.length; i++)
{
if (divArray[i].class="productitemcell")
alert(divArray[i].innerHTML);
}
}
displaymessageNow();
But this is obviously not the final result we are after.
We need to be able to find the words "1 line custom" in the background (so the user dosnt see this happening) then once these words are found display a link.
The call to escape() is there because spaces in URLs can cause hiccups, so you encode the URL (and the browser will automatically decode it...converting %20 to space, etc.).
Ok ok, I'm liking this that is very very close to what we are after, however there is still a small issue.
It would be preferable if the first two div classes "Champagne Weadding" and "Party Like 1999" didnt generate as links.
Code:
<table>
<tbody>
<tr>
<td><div class="productitemcell">Champagne Weadding</div>
<div class="productitemcell">Party Like 1999</div></td>
<td><div class="productitemcell">1 line custom</div>
<div class="productitemcell">2 line custom</div></td>
</tr>
</tbody>
</table>
Now keeping in mind that we have no control over removing the <div class="productitemcell"></div> wrapped around them as this is a function of the CMS we are using, However we could wrap it all in a div id or something if that would help like this:
Code:
<table>
<tbody>
<tr>
<td><div id="removeLink">
<div class="productitemcell">Champagne Weadding</div>
<div class="productitemcell">Party Like 1999</div>
</div></td>
<td><div class="productitemcell">1 line custom</div>
<div class="productitemcell">2 line custom</div></td>
</tr>
</tbody>
</table>
function addLinks( )
{
var changeOnly = document.getElementsByClassName("changeLinks");
for ( var c = 0; c < changeOnly.length; ++i )
{
var divArray = changeOnly[c].getElementsByClassName("productitemcell");
for (var i = 0; i<divArray.length; i++)
{
var div = divArray[i[;
div.innerHTML = '<a href="/' + escape(div.innerHTML) + '">' + div.innerHTML + '</a>';
}
}
}
window.onload = addLinks;
Now here is the thick box code implemented into the JS you wrote for us previously (thick box stuff in red):
Code:
function addLinks()
{
var changeOnly = document.getElementsByClassName("changeLinks");
for ( var c = 0; c<changeOnly.length; ++c )
{
var divArray = changeOnly[c].getElementsByClassName("productitemcell");
for (var i = 0; i<divArray.length; i++)
{
var div = divArray[i];
div.innerHTML = '<a href="/customise-forms/' + escape(div.innerHTML) + '?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=200&width=300&modal=true" class="thickbox" title="Form 1">' + div.innerHTML + '</a>';
}
}
}
window.onload = addLinks;
The URL it spits out seems to be fine and in theory it should work but as it is it just sends you to the actual page instead of opening up in thick box. Can you see anything in the code that would stop the thick box from working.