maverick Posted February 13, 2013 Report Share Posted February 13, 2013 Hi, I am a caspio rookie and need some help with my Search and Report Datapage Basically my table has a field "Membership" which can have 3 levels - Basic, Pro and Premium. Depending on level of membership I need to display a different HTML link in a "Search and Report Datapage". I looked thru the forum and see that I can retrieve records via getElementById("InsertRecordMemebership").value OR getElementById("EditRecordMemebership").value. Not sure when I should use "InsertRecord" vs "EditRecord". I'm thinking that I need to run some javascript code and use either jquery's .html() API or innerHTML to accomplish this. Can someone please help me out with this or guide me in the right direction? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
maverick Posted February 14, 2013 Author Report Share Posted February 14, 2013 So I tried the following in the HTML block of my Datapage a) Jquery's html() API (the place where this datapage is deployed has jquery) var membership = '[@field:Membership]'; if (membership == 'Basic') { $("#biz-name").html("[@field:Company_name]"); } innerHTML var membership = '[@field:Membership]'; if (membership == 'Basic') { document.getElementById('biz-name').innerHTML ='[@field:Company_name]'; } In both cases, when the search returns multiple records, _ONLY_ the 1st record is updated. However it has the value of the _LAST_ record's Company_name. Does anyone know how to tweak this to make it work on a per-record basis? I would really appreciate the help. Quote Link to comment Share on other sites More sharing options...
casyana Posted February 16, 2013 Report Share Posted February 16, 2013 I would propose you to use the following JS in the HTML block: if ( '[@field:Membership]' == 'Basic') document.write(' Link 3 '); Quote Link to comment Share on other sites More sharing options...
maverick Posted February 16, 2013 Author Report Share Posted February 16, 2013 Thanks for your suggestion casyana. Actually I thought about document.write() earlier today morning and tried it out. And it does indeed work, whew! The reason why I had jumped at innerHTML or .html() first was because document.write() is generally frowned upon, isnt it? I tried it out in Chrome, Firefox and IE 8.0 & 9.0 and it does seem to work. Hoping that this will work across all browsers.. Quote Link to comment Share on other sites More sharing options...
casyana Posted February 19, 2013 Report Share Posted February 19, 2013 Hi Maverick I'm glad, that it helped. I don't think you will experience any issue with document.write, it is supported in all major browsers: http://www.w3schools.com/jsref/met_doc_write.asp Regards, Casyana. 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.