Jump to content

user driven list


eliggins

Recommended Posts

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

servicesList.JPG.c8951f850564b40212626c2d300da76a.JPG

Edited by Dan Korn
Might as well actually show the picture in the post.
Link to comment
Share on other sites

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();

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...