"); text = (text +"
"); text = (text + "Friends, Romans, " +form.input1.value+ " lend me your " +form.input2.value+ "; "); text = (text + "I come to " +form.input3.value+ " Caesar, not to praise him. "); text = (text +"The evil that men do lives after them, the good is oft interred with their " +form.input4.value+ "; "); text = (text +"so let it be with " +form.input5.value+ ". " ); text = (text +"The noble Brutus hath told you Caesar was " +form.input6.value+ "; if it were so, it was a grievous fault. "); text = (text +"If you have " +form.input7.value+ ", prepare to shed them now. "); text = (text +"You all do know this " +form.input8.value+ ". "); text = (text +"I remember the first time Caesar put it on. "); text = (text +"Through this well-beloved Brutus stabbed; for Brutus, as you know, was Caesar's " +form.input9.value+ ": "); text = (text +"this was the unkindest " +form.input10.value+ " of all. "); text = (text +"Here is the " +form.input11.value+ ", under Caesar's seal. To every Roman " +form.input12.value+ " he gives, "); text = (text +"to every several man, seventy five " +form.input13.value+ ". "); text = (text +"Here was a/an " +form.input14.value+ "! When comes another?"); msgWindow=window.open("","displayWindow","toolbar=no,width=375,height=480,directories=no,status=no,scrollbars=yes,resize=no,menubar=no") msgWindow.document.write(text) msgWindow.document.close() } } // --> for May 20, 1996: Using forms and windows together
That's all great, but where's the fun in windows? Add forms and windows suddenly become more useful; I have used a "Madlibs" like example to show this. Quickly fill in the form, and then press the button to see how it all works.
Neat, huh? You all know how to create a window by now but do you know how to write to a window, and send form data to a specific window? First you have to create a form and give each object in the form a name. In this example, there are 14 input boxes, each named input1, input2, etc. After the user fills in the boxes, the data is sent to a function by pressing the Create Window button. The code for this is simple:
<INPUT TYPE="button" VALUE="Create Window" onClick="create(this.form)">
text = ("Friends, Romans, " + form.input1.value + " lend me your " + form.input2.value + "; ");
Now you must create a blank window. Then take the string text and write it to that window:
msgWindow=window.open("", <-- Notice a URL is not required "displayWindow", "toolbar=no, width=375, height=480, directories=no, status=no, scrollbars=yes, resize=no, menubar=no") msgWindow.document.write(text) msgWindow.document.close()