Jump to content

Tough One


p.kennedy

Recommended Posts

I have two text boxes that will fill from the bottom up but the client wants the top lines of each box to always be level. The code I have is below. It is not working any Ideas?

 

 

// Create an array with the fields you'd like to show up on the right

var rightFieldArray = [Field("Address1"),Rule("CommaRule"),Field("Address2"),Field("City"),Rule("CityCommaRule"),Field("State"),Field("Zip"),Field("Field1"),Field("Field2"),Field("Filed3"),Field("Number1"),Field("Number2"),Field("Number3"),Field("EmailAddress"),Field("URL")];

var leftFieldArray = [Field("Name"),Field("Title"),Field("Title2"),Field("Title3"),Field("Division")];

 

// Create an array to hold the fields that have a value

var rightArray = [];

var leftArray = [];

 

// Populate RightArray with only fields that hold a value

for (var i=0; i < rightFieldArray.length; i++){

(rightFieldArray != "" ) ? rightArray.push(rightFieldArray) : "";

}

 

// Determine how many lines the left will need to be indented based on

// how many lines the rightArray has populated

var indent = rightFieldArray.length - rightArray.length;

 

// Fill the first positions in the leftArray with blanks to adjust for the

// difference in array length

for (var z=0; z < indent; z++){

leftArray.push(" ");

}

 

// populate the remaining positions in the leftArray with populated fields held

// within leftFieldArray

for (var n=0; n < leftFieldArray.length; n++){

(leftFieldArray[n] != "" ) ? leftArray.push(leftFieldArray[n]) : "";

}

 

// Populate each text frame with their respective array

FindTextFrame("Right").content = rightArray.join("<br>");

FindTextFrame("Left").content = leftArray.join("<br>");

Link to comment
Share on other sites

Looks like you ripped the code from my post in this thread.

 

If you read the original post, you'll see that he has two text boxes, one aligned to the top and one aligned to the bottom. If both of yours are aligned to the bottom, you'll have to adjust the order the "blanks" are pushed into the leftArray.

Link to comment
Share on other sites

I did swip that code! My main problem for now is that in the right box the code is re-organizing the format of the text box. So instead of looking like this:

Address1

Address2

City, State Zip

Field1 number1

Field2 Number2

Field3 Number three

Email

Url

 

it looks like this:

Address1

Address2

City

,

State

Zip

Field1

number1

Field2

Number2

Field3

Number3

Email

Url

Link to comment
Share on other sites

I think you'll have to set up something to handle the fields you want to be on a single line (City, ST ZIP) and then replace them in the array with a variable.

 

For example:

var field1 = [Field("Field1"),Field("Number1")].join(" ");

 

Then instead of this:

var rightFieldArray = [Field("Address1"),Rule("CommaRule"),Field("Address 2"),Field("City"),Rule("CityCommaRule"),Field("Sta te"),Field("Zip"),[color="red"]Field("Field1")[/color],Field("Field2"), Field("Filed3"),[color="red"]Field("Number1")[/color],Field("Number2"), Field("Number3"),Field("EmailAddress"),Field("URL" )];

 

You'd have something like this:

var rightFieldArray = [Field("Address1"),Rule("CommaRule"),Field("Address 2"),Field("City"),Rule("CityCommaRule"),Field("Sta te"),Field("Zip"),[color="Red"]field1[/color],Field("Field2"), Field("Filed3"),Field("Number2"), Field("Number3"),Field("EmailAddress"),Field("URL" )];

Link to comment
Share on other sites

This is the code I ended up using. I just can't figure out the formatting thing??

 

// Create an array with the fields you'd like to show up on the right

var rightFieldArray = [Field("Address1"),Field("Address2"),Field("City")+Rule("CityCommaRule")+Field("State")+(" ")+Field("Zip"),Field("Field1")+(" ")+Rule("PhoneRule1"),Field("Field2")+(" ")+Rule("PhoneRule2"),Field("Filed3")+(" ")+Rule("PhoneRule3"),Field("EmailAddress"),Field("URL")];

 

 

var leftFieldArray = [Field("Name"),Field("Title"),Field("Title2"),Field("Title3"),Field("Division")];

 

// Create an array to hold the fields that have a value

var rightArray = [];

var leftArray = [];

 

// Populate RightArray with only fields that hold a value

for (var i=0; i < rightFieldArray.length; i++){

(rightFieldArray != "" ) ? rightArray.push(rightFieldArray) : "";

}

 

// Determine how many lines the left will need to be indented based on

// how many lines the rightArray has populated

var indent = rightFieldArray.length - rightArray.length;

 

// Fill the first positions in the leftArray with blanks to adjust for the

// difference in array length

for (var z=0; z < indent; z++){

leftArray.push(" ");

}

 

// populate the remaining positions in the leftArray with populated fields held

// within leftFieldArray

for (var n=0; n < leftFieldArray.length; n++){

(leftFieldArray[n] != "" ) ? leftArray.push(leftFieldArray[n]) : "";

}

 

// Populate each text frame with their respective array

 

FindTextFrame("Right").content = rightArray.join("<br>");

FindTextFrame("Left").content = leftArray.join("<br>");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...