BFuchs Posted December 16, 2019 Report Share Posted December 16, 2019 Hi, I have a calculated field in a tabular report results with the following value. (SELECT COUNT(nurse_id) FROM users WHERE nurse_id=[@field:Nurse_ID]) Then I have an HTML link based on that calculated field, as follows <a href="" id="myLink"></a> <script> if([@calcfield:1#] != 0) { document.getElementById("myLink").innerHTML = "Edit Password"; document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID"; document.getElementById("myLink").target = "_blank"; } else { document.getElementById("myLink").innerHTML = "Add Password"; document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID"; document.getElementById("myLink").target = "_blank"; } </script> This works as expected but only for first row. How can I have this feature working for each row in the report? Thanks Quote Link to comment Share on other sites More sharing options...
1 douvega Posted December 16, 2019 Report Share Posted December 16, 2019 Thanks, the following code should work: <a href="#" id="myLink_[@field:Nurse_ID]" target="_blank"></a> <script> if([@calcfield:1#] > 0){ document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Edit Password"; document.getElementById("myLink_[@field:Nurse_ID]").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=[@field:Nurse_ID]"; }else{ document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Add Password"; document.getElementById("myLink_[@field:Nurse_ID]").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=[@field:Nurse_ID]"; } </script> I was not able to test this code but please let me know if it works as expected. Quote Link to comment Share on other sites More sharing options...
0 douvega Posted December 16, 2019 Report Share Posted December 16, 2019 Hi @BFuchs Your code is not working for all rows since you are generating several items with the same id "myLink", remember each id must be unique. Could you please identify a field within the table which is unique so I can provide you with the proper JS? Tell me the full name of the unique field. BFuchs 1 Quote Link to comment Share on other sites More sharing options...
0 BFuchs Posted December 16, 2019 Author Report Share Posted December 16, 2019 3 minutes ago, douvega said: Hi @BFuchs Your code is not working for all rows since you are generating several items with the same id "myLink", remember each id must be unique. Could you please identify a field within the table which is unique so I can provide you with the proper JS? Tell me the full name of the unique field. Hi douvega, Field Nurse_ID should be unique. Thanks, Ben Quote Link to comment Share on other sites More sharing options...
0 BFuchs Posted December 16, 2019 Author Report Share Posted December 16, 2019 6 minutes ago, douvega said: Thanks, the following code should work: <a href="#" id="myLink_[@field:Nurse_ID]" target="_blank"></a> <script> if([@calcfield:1#] > 0){ document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Edit Password"; document.getElementById("myLink_[@field:Nurse_ID]").href = "https://c2esh547.caspio.com/dp/0ab94000a09b2aef99b84547b2b8?Nurse_ID=[@field:Nurse_ID]"; }else{ document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Add Password"; document.getElementById("myLink_[@field:Nurse_ID]").href = "https://c2esh547.caspio.com/dp/0ab9400088235fb518164a2b828e?Nurse_ID=[@field:Nurse_ID]"; } </script> I was not able to test this code but please let me know if it works as expected. Looks like the HTML portion is working now, but perhaps something is wrong with the calculated field as well. See attached. Thanks, Ben Quote Link to comment Share on other sites More sharing options...
0 BFuchs Posted December 16, 2019 Author Report Share Posted December 16, 2019 23 hours ago, BFuchs said: Hi, I have a calculated field in a tabular report results with the following value. (SELECT COUNT(nurse_id) FROM users WHERE nurse_id=[@field:Nurse_ID]) Then I have an HTML link based on that calculated field, as follows <a href="" id="myLink"></a> <script> if([@calcfield:1#] != 0) { document.getElementById("myLink").innerHTML = "Edit Password"; document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID"; document.getElementById("myLink").target = "_blank"; } else { document.getElementById("myLink").innerHTML = "Add Password"; document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/3456?Nurse_ID=&Nurse_ID"; document.getElementById("myLink").target = "_blank"; } </script> This works as expected but only for first row. How can I have this feature working for each row in the report? Thanks Actually I just had to add Target.Nurse_ID and it works. Thank you douvega!! Quote Link to comment Share on other sites More sharing options...
Question
BFuchs
Hi,
I have a calculated field in a tabular report results with the following value.
Then I have an HTML link based on that calculated field, as follows
This works as expected but only for first row.
How can I have this feature working for each row in the report?
Thanks
Link to comment
Share on other sites
5 answers to this question
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.