New to javascript and need some help

Discussion in 'JavaScript' started by Abneo, Feb 15, 2008.

  1. #1
    Hi all,

    I am now writing a code for madlib. I have that part of the code done. I want the results of the madlib code to display in a second frame. More or less I want the user to put in their input on the right frame and when they click create story I want it to display in a textarea in the left frame. Here is the code for the mablib

    
    <html>
    <head>
    <SCRIPT LANGUAGE = "JavaScript">
    function create(form) { 
    if (confirm("Are you sure?")) { 
    storyWin = document.getElementById("madlibresults"); 
    with (storyWin.document) { 
    writeln ("<P><b> One day while I was " + form.input1.value + " in the " + form.input2.value + " a " + form.input3.value + " " + form.input4.value + " fell through the roof. It immediately jumped on the " + form.input5.value + " and knocked over the </b>"); 
    writeln ("<b>" + form.input6.value + ". Then it ran out the door into the " + form.input7.value + " and " + form.input8.value + " a " + form.input9.value + " off the " + form.input10.value + ". </b>"); 
    writeln ("<b> It then knocked a glass of " + form.input11.value + " off the coffee table. After " + form.input12.value + " minutes of chasing the " + form.input4.value + " through the house I finally caught it and put it outside. It quickly climbed the nearest " + form.input13.value + ".</b>"); 
    writeln ("<BR>"); 
    } 
    }
    }
    </SCRIPT>
    </head>
    
    <BODY>
    
    <CENTER>
    <FORM>
    <TABLE BORDER = 1 CELLPADDING = 0>
    <TR><TD>
    <b>Verb:</b>
    <TD><INPUT TYPE="text" NAME="input1" size=45><BR>
    </TD></TR><TR><TD>
    <b>Room in a House:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input2" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Adjective:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input3" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Noun:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input4" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Piece of Furniture:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input5" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Noun:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input6" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Room in a House:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input7" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Verb:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input8" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Noun:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input9" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Piece of Furniture:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input10" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>A Liquid:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input11" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Number:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input12" size=45 ><BR>
    </TD></TR><TR><TD>
    <b>Noun:</b>
    </TD><TD>
    <INPUT TYPE="text" NAME="input13" size=45 >
    </TD>
    </TR>
    <TR>
    <TD>
    </TD>
    </TR>
    </TABLE>
    <BR></B>
    <INPUT TYPE = "button" VALUE="Create Story" onClick = "create(this.form)">
    </FORM>
    </CENTER>
    <html>
    
    Code (markup):
    Here is the code for the results page. I am not sure what else I need to add to this to make it all work. I want the results to display in the window without the user having to scroll.

    
    <html>
    <body>
    <CENTER>
    <textarea style="border=0; overflow=auto;" name=msg rows="30"cols="50">
    </body>
    </html>
    
    Code (markup):
    Any and all help is welcome and I would be very thankful for any offered.
     
    Abneo, Feb 15, 2008 IP