show inputed as html in a new window

sup ppl,

I have designed program that selects a day and meal and prints it onto a by writting a function. The function is assigned to a button. I wish to create another button that takes the value of the text area, as selected by a user, and displays the information onto a new html page. This how my could currently looks:




var recipes = new Array ("http://vegetarian.allrecipes.com/AZ/CrridVgtbls.asp","http://maindish.allrecipes.com/az/clssicpizzmrghrit.asp","http://vegetarian.allrecipes.com/az/chsyvgtbllsgn.asp","http://vegetarian.allrecipes.com/az/cauliflowercheesepie.asp","http://vegetarian.allrecipes.com/az/rtichkspinchlsgn.asp","http://vegetarian.allrecipes.com/az/mricnstylrdbnsndric.asp","http://vegetarian.allrecipes.com/az/addictivesweetpotatoburrit.asp","http://pasta.allrecipes.com/AZ/llisDlicisMcrniChs.asp","http://vegetarian.allrecipes.com/az/blackbeansandrice.asp","")
var detailsWindow;
var copyText;
function selectButton_onclick()
{
document.form1.txtSelect.value=document.form1.txtSelect.value + document.form1.theDay.options[document.form1.theDay.selectedIndex].text +":- " +document.form1.menu.options[document.form1.menu.selectedIndex].text + ".
";
}

function viewButton_onclick()
{
detailsWindow = window.open(recipes[document.form1.menu.selectedIndex]);
detailsWindow.focus;

}

function copyButton_onclick()
{
copyText = window.open("Print.html","finalList","width=150,height=150");
copyText.document.open();
copyText.document.write("
Meal Plan for the Week
");
copyText.document.write(document.form1.txtSelect.value)
copyText.focus;

}








Vegetarian Meal Planner


Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday


Curried Vegetables
Classic Pizza Margharita
Cheesy Vegetable Lasagna
Cauliflower Cheese Pie
Artichoke Spinach Lasagna
American-Style Red Beans and Rice
Addictive Sweet Potato Burritos
Black Beans and Rice
Takeaway















It kinda works but not the way I want it to. It displays the value but in a longsentece with no breaks. Please help!!!!!!!


Comments

  • :I have designed program that selects a day and meal and prints it onto a by writting a function. The function is assigned to a button. I wish to create another button that takes the value of the text area, as selected by a user, and displays the information onto a new html page. This how my could currently looks:
    :It kinda works but not the way I want it to. It displays the value but in a long sentece with no breaks. Please help!!!!!!!

    Okay, try to determine where the line breaks in the textarea.
    Try putting in a '|' in after they press 'select'. the user will hardly notice it, and, when they press 'test', you can use my function to replace it with '
    '.
    Use a variable that, when the user presses 'test', the value of the textarea is set to it. then use my function to replace '|' with '
    '
    Then, when you open the window, use the variable that you've formatted with '
    's, instead of 'document.form1.txtSelect.value'

    I have the function saved at home, and will get on the web here in about 4 to 5 hours.

    have fun!
    [hr]
    [blue]Visual Basic[/blue]
    ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    My Website:
    http://www.geocties.com/joesarcade :-(
    [red]JavaScript[/red]
    [hr]


  • :
    : I have the function saved at home, and will get on the web here in about 4 to 5 hours.
    :
    Here's the function:
    Sorry it took so long!

    [code]
    function check(){
    var stringThing = document.toCheck.theText.value
    var myReplace = "|" //must be 1 char long
    var myReplaceWith = "
    "
    /*
    DO NOT place a character in 'myreplacewith'
    that is the same as 'myreplace'!!!!!
    IF YOU DO, YOU WILL ENTER AN ENDLESS LOOP!!!
    */

    for(i=1;i<stringThing.length + 1;i++){
    if (stringThing.substring(i - 1, i) == myReplace){
    document.toCheck.theText.value = stringThing.substring(0, i - 1) + myReplaceWith + stringThing.substring(i, stringThing.length)
    stringThing = document.toCheck.theText.value
    check()
    }
    }


    }
    [/code]

    Remember to replace 'document.toCheck.theText.value' with your textarea.
    [b](it appears twice)[/b]
    [hr]
    [blue]Visual Basic[/blue]
    ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    My Website:
    http://www.geocties.com/joesarcade :-(
    [red]JavaScript[/red]
    [hr]

  • I sad to say that the function did not work. Although that did motivate me to find a function that did work and I have found that has. Basically I used the split function to go through and the stored value and split each selection. I am not good explaining these things but I will just show the code I suppose you will be able to figure out what I have done.

    function check_onclick()
    {
    var txt_area = document.form1.txtSelect.value;

    var new_window = window.open("","something", "width=400,height=400");

    new_window.document.writeln("
    The Final Menu List
    ");

    var txt_array = txt_area.split(".");

    for (var loop=0; loop < txt_array.length; loop++)
    {

    new_window.document.writeln("
    " + txt_array[loop] + ".

    ");
    }

    }

  • : I sad to say that the function did not work. Although that did motivate me to find a function that did work and I have found that has. Basically I used the split function to go through and the stored value and split each selection. I am not good explaining these things but I will just show the code I suppose you will be able to figure out what I have done.
    :
    There were a couple customizations you had to preform on the function. I was hoping that you would find them. I've tested the function, and it does work, but you have to skim through and examine it before it works correctly.
    [hr]
    [blue]Visual Basic[/blue]
    ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    My Website:
    http://www.geocties.com/joesarcade :-(
    [red]JavaScript[/red]
    [hr]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories