Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

putting something in a textarea under script control

Status
Not open for further replies.

platypus55

Programmer
Aug 15, 1999
32
0
0
US
I decided to try another tack. <br>
<br>
I would like to open a pre existing html file in a new window. This pre-existing file has an empty textarea called custom<br>
in a form called puzzledata. My script is doing a beautiful<br>
job of generating html code. How can I take the beautiful<br>
code that I just generated and put it into the text area? <br>
<br>
if I say<br>
<br>
jsx = open("codefile.html","jsx", ...<br>
jsx.document.puzzledata.custom.value = "FOO" <br>
<br>
that doesn't work, (the simple case) so it won't do multiline stuff either.
 
hmmm.... I know you're wanting a quick fix; but if you go to you'll have access to a library of JS source as well as a couple of tutorials; don't know if the library will help any; but a month spent on the tutorials would *definately* be of *great* benefit to you.<br>
<br>
<br>
-Robherc
 
This code below loads some html passed as a variable into a TextArea. You should be able to adapt it to your needs. As far as the multiline stuff, make sure you set the Textarea's Wrap property to "Hard".<br>
<br>
&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;<br>
&lt;script language="JavaScript"&gt;<br>
function showCode () {<br>
var html = "&lt;b&gt;HTML in my Textarea&lt;/b&gt;\n"<br>
html += "&lt;i&gt;a second line of html&lt;/i&gt;" <br>
document.forms[0].txaShowCode.value = html<br>
}<br>
&lt;/script&gt;<br>
&lt;/head&gt;&lt;body onload="showCode();"&gt;<br>
&lt;form&gt;<br>
&lt;textarea name="txaShowCode" rows="5" cols="50" wrap="hard"&gt;&lt;/textarea&gt;<br>
&lt;/form&gt;<br>
&lt;/body&gt;&lt;/html&gt;<br>
<br>
<br>

 
Thanks for the code. Actually the problem I was having was putting anything into a textarea in ANOTHER window.<br>
<br>
I'm pretty sure it has something to do with "blur" or "focus" or something like that. I've been through several of the advanced webmonkey tutorials suggested by the previous poster, plus I've searched in my O'Reilly book and I still haven't found the answer to the question. I ended up kludging. I opened the window with one button, then did another button to put the stuff in the textarea. It works but it isn't as slick as I'd like.
 
Have you tried using the onload event for the body tag, like in the code sample I provided above?
 
No, I haven't tried that. There are a million ways to do the same thing, no? The deal is, the HTML is generated in the generate window, into a variable you called html. When the variable is all finished I would just like to say:<br>
<br>
open otherwindow<br>
otherwindow.document.forms[whatever].txaShowCode.value = html<br>
<br>
How would you do an onload in the new window referring to a routine or a variable in the opener window? And doesn't opener only work for level 4+ browsers? <br>
<br>
<br>
Actually, looking at your code vs. my code, you might have just given me the clue why mine didn't work in the first place. I didn't do forms[whatever] in mine because I think I made a conceptual boo-boo as to the scope of a name within a form. I was treating it like an image which is global to the whole thing. I'll give this program another look in the next few days because that would really slicken it up if the user only has to click one button when he is done entering the data. <br>
<br>
Thanks for reactivating the thread. We can all learn all the time!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top