SteelNerveDesigns Posted June 22, 2011 Report Share Posted June 22, 2011 Hey all! Long time reader, first time poster! I've got an issue that's probably killing a lot of us. The situation is like this in my table I have 7 columns that are yes or no and we'll just talk about 3 of them for now. They are GF, CF, MSG. I want to have one of my search pages report back in the following format: Codes: GF, CF, MSG The "Codes:" is html but the 3 fields would only show based on whether or not they were marked true or false this is the jscript i have so far var td = document.getElementsByTagName("td"); for (var i = 0; i < td.length; ++i) { var tdElems = td.childNodes; for(var j = 0; j < tdElems.length; ++j) { if(tdElems[j].tagName == "SPAN") { if(tdElems[j].innerHTML == " " || tdElems[j].innerHTML == "" || tdElems[j].innerHTML == "No") { tdElems[j].style.display = "none"; tdElems[j - 1].style.display = "none"; if(tdElems[j-2].tagName == "BR") tdElems[j - 2].style.display = "none"; } } } } It works perfectly when I have 1 field per line but it goes to hell when i have all 3 fields on 1 line so it'll work like: Codes: GF Codes: CF Codes: MSG (if all 3 columns are true for that record) but it won't work when they're all on the same line my guess is it looks like Codes: GF Codes: CF Codes: MSG and Codes: GF, CF, MSG Anyone got any ideas? My ultimate goal is simply this: How can I make 7 True/False fields concatenate on 1 line? i.e. Codes: CF, GF, MSG Quote Link to comment Share on other sites More sharing options...
ShWolf Posted June 12, 2012 Report Share Posted June 12, 2012 Hi, What do you put in the HTML block? Only spans with 'Codes'? Or you also put there values of Yes/No fields with [@field:...] in another spans? Quote Link to comment Share on other sites More sharing options...
ShWolf Posted June 13, 2012 Report Share Posted June 13, 2012 Hi, As I understand, on the results page you have seven Yes/No fields (with standard formating Yes/No), and you have one HTML Block where you want to display column names for Yes/No fields (GF, CF, MSG etc.) only if there is "Yes" value. Try to insert following code into the footer on the 'Configure Results Page Fields' page: <script type="text/javascript"> var v_index = 0; var v_ths = document.getElementsByTagName('th'); var v_trs = document.getElementsByTagName('tr'); for(var v_i=0; v_i<v_trs.length;v_i++){ var v_tds = v_trs[v_i].getElementsByTagName('td'); if (v_tds){ for(var v_j=0;v_j<v_tds.length;v_j++){ if (v_tds[v_j].innerHTML=='Yes'){ v_tds[v_index].innerHTML+= v_ths[v_j].innerText||v_ths[v_j].textContent||v_ths[v_j].text; if (!v_tds[v_j+1]) break; for(var v_k=v_j+1;v_k<v_tds.length;v_k++){ if (v_tds[v_k].innerHTML=='Yes'){ v_tds[v_index].innerHTML+=', '; break; } } } } } } </script>And replace value for var v_index with corresponding cell number of the HTML Block in you page (numbering begins from zero).Code from example with 0 value for var v_index works when HTML Block inserted before all fields on the 'Configure Results Page Fields' page. Let me know if this helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.