eliggins Posted October 13, 2015 Share Posted October 13, 2015 (edited) I'm trying to recreate a product (see attachment below), the way it works is, there is a total of 14 fields that can be filled. The user is prompted to choose a number of services (1 to 14) they can then fill out the title description and rate. I initially thought I could possibly accomplish this by using the FPTables scripts to create a dynamic table that would populate the rows...dynamically based on the selected amount of services, but not really sure where to start. Could anyone tell me if this would be the best way to accomplish this and how, or is there some built ins. As a side note I'm using the Marcomcentral platform. Any help is greatly appreciated http://forums.pti.com/attachment.php?attachmentid=1342&d=1444767266 Edited October 13, 2015 by Dan Korn Might as well actually show the picture in the post. Quote Link to comment Share on other sites More sharing options...
step Posted October 13, 2015 Share Posted October 13, 2015 I'm trying to recreate a product (see attachment below), the way it works is, there is a total of 14 fields that can be filled. The user is prompted to choose a number of services (1 to 14) they can then fill out the title description and rate. I initially thought I could possibly accomplish this by using the FPTables scripts to create a dynamic table that would populate the rows...dynamically based on the selected amount of services, but not really sure where to start. You can definitely do this with tables. In fact a simple search of the forums would point you to several threads of people doing exactly what you're asking (http://forums.pti.com/showthread.php?t=3179 or even http://forums.pti.com/showthread.php?t=2087) but I digress. You say there are (up to) 14 fields but the example you posted looks more like there will be 3 fields per service. Here's a generic way to get you where you're trying to go: var fields = [ Field('Service1'), Field('Service2'), ].filter(String); var table = new FPTable; table.AddColumns(7200); // 7200 = 1 inch column table.ShadingColor1 = "White"; table.ShadingPct1 = 100; table.ShadingColor2 = "Khaki"; table.ShadingPct2 = 100; table.ShadingType = "ByRow"; for (var i in fields) { var row = table.AddRow(); row.SetContents(fields[i]); } return table.MakeTags(); Wherein you can add as many fields as you'd like to that "fields" array. If all of the fields are named "Service" followed by a sequential number, you could populate that array using a for loop: var fields = []; for (var i=1; i<=14; i++) fields.push(Field('Service' + i)); fields = fields.filter(String); If each service has it's own corresponding "Title," "Description," and "Rate" field, the code would look more like this: var fields = []; for (var i=1; i<=14; i++) fields.push([Field('Title' + i), Field('Description' + i), Field('Rate' + i)]); fields = fields.filter(function(s){ return s.join(''); }); var table = new FPTable; table.AddColumns(7200, 7200); // 7200 = 1 inch column table.ShadingColor1 = "White"; table.ShadingPct1 = 100; table.ShadingColor2 = "Khaki"; table.ShadingPct2 = 100; table.ShadingType = "ByRow"; for (var i in fields) { var row = table.AddRow(); var col = row.Cells[0]; col.CopyCells(0,1); var [title, description, rate] = fields[i]; row.SetContents(title + '<br>' + description, rate); } return table.MakeTags(); Quote Link to comment Share on other sites More sharing options...
eliggins Posted October 14, 2015 Author Share Posted October 14, 2015 Thanks for getting back to me, this looks pretty straight-forward, however, I'm still having a problem. How should I setup my template, do I create one big text frame and apply the script name to it? 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.