I'm making a recipe program and have created the following array (this is only the important part):
var r = new Array();
r[0]=new Array("Apple Pie","Dessert","5-6 Cooking Apples 1 1/4 Cups Granulated Sugar.");
I need a line break between the two ingredients and nothing is working for me - I tried \n and other stuff;<br> is interpreted as part of the string and <pre> didn't work either.
The information is written to a different page and is located inside a table. This other page references a javascript document where the arrays are located.
I need a line break between the two ingredients and nothing is working for me - I tried \n and other stuff;<br> is interpreted as part of the string and <pre> didn't work either.
well, one of those should work. can you post the code so we can see if something else is wrong?
Here is the code - nothing else should be wrong because my teacher majorly started me off.... As you can probably see, I need to have line breaks between the ingredients and directions instead of the text coming in as one solid block.
Thanks so much!
var r = new Array();
r[0]=new Array("Apple Pie","Dessert","me","5-6 Cooking Apples 1 1/4 Cups Granulated Sugar 1 tsp Cinnamon 1/8 tsp Nutmeg Pastry for a two-crust pie 3 tbsp Butter or Margarine","1. Peel, core, and slice the apples. 2. Preheat the oven to 425 degrees. 3. Roll out half the dough and line a 9-inch pie plate with it. Arrange the apple slices over the bottom of the pastry, packing the slices closely and letting them pile up. 4. Combine the sugar, cinnamon, and nutmeg, and coat the apples with the mixture. Dot with tablespoons of butter or margarine. 5. Roll out the remaining dough. Wet the rim of the bottom crust and put the top crust on. Trim and crimp the crust. Prick the upper crust with a design. Bake the pie at 425 degrees for 15 minutes, then lower temperature to 375 for remaining 30 minutes or until pie begins to bubble through design and is delicately browned.");
it it helps, each of these index elements comes into a separate box on a different page (so the ingredients are in one box and the directions are in another).
From looking at your array, there's nothing to really determine where there should be line breaks, there's no delimiter that says 'this ingredient finished, move onto the next one. In order to be able to format the text as you output it, then you require something to tell you how it should be formatted.
For example, in your ingredient array you have:
Code:
5-6 Cooking Apples 1 1/4 Cups Granulated Sugar 1 tsp Cinnamon 1/8 tsp Nutmeg Pastry for a two-crust pie 3 tbsp Butter or Margarine
Do you have access to control the database/XML file/text file/whatever that this stuff is stored in? If you do, then you need to store it as something that separates the ingredients, whether it be commas or br's:
Code:
5-6 Cooking Apples,1 1/4 Cups Granulated Sugar,1 tsp Cinnamon,1/8 tsp Nutmeg,Pastry for a two-crust pie,3 tbsp Butter or Margarine
Barring this, there is really no way to reliably break up your string of ingredients into a list of ingredients on separate lines.
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
awesome.
If you want to write to a textarea, just insert newline commands "\n". This was done in the next link.htm to create a narrative telling round robin participants how to create their schedule.
As much as I understand how posts started to get onto the topic of \r\n - through wbport's post about textareas, because s/he apparently didn't read enough of this thread to realize what the actual problem was - I must post again and refer the OP back to my post (#10) as it describes what the actual problem is and how to fix it.....and it has nothing to do with textareas, \n's, \r\n's, or br's.
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
awesome.
Bookmarks