Jump to content

[SOLVED] Getting stuff out of textarea and populating it in a frame


blufish

Recommended Posts

Heres my question, If I have a textarea, on one half of my page and on the other half I have a frame which contains whatever is written inside the textarea, how do I get it so that as soon as you change the textarea the frame changes it's contents to match the textarea.

 

Thanks, Blufish

So you got 2 frames right? Let's call frame1 => a.html and frame2 => b.php

 

So let's say your textarea is in frame1 and your display will be in frame2.

 

So in fram1, you put a form like this:

<form name="postTextToFrame2" action="b.php" method="post" target="frame2">
<textarea name="myText" cols="50" rows="5"></textarea>
<input type="submit" value="Post!" />
</form>

 

So the data will be posted to the target frame. Then in frame2 (the "b.php"), you will just do something like this:

<?php
if(isset($_POST['myText'])) {
    // Print out your text!!!
    echo $_POST['myText'];
}

?>

Figured it out for you mate.

 

<html>
<head>
<script type="text/javascript">
<!--

function addText(){

window.document.myForm.txtOut.value=window.document.myForm.txtIn.value;

}
//-->
</script>
</head>
<body>
<form method="post" name="myForm">
<center>
Enter text in this box:<br /><br />
<textarea name="txtIn" cols="30" rows="5" onKeyUp="addText()"></textarea>
<br /><br /><br />
And it will appear in this one:<br /><br />
<textarea name="txtOut" cols="30" rows="5"></textarea>
</form>
</body>
</html>

 

Definately works, I already tested it... :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.