Forum Moderators: coopster

Message Too Old, No Replies

Echo data to textarea box?

Need help please!

         

spyder_tek

2:26 am on Feb 3, 2006 (gmt 0)

10+ Year Member



Hi,

I'm trying to create a script that echoes javascript/html code to a textarea box depending on which checkboxes are selected.

So if all checkboxes are selected, it echoes all the data associated with each checkbox in the correct order.

So far this is what I have:

<?php

if (isset($_POST['checkbox1'])) {

echo "echo this javascript data to mybox textarea";

}

if (isset($_POST['checkbox2'])) {

echo "echo this javascript data to mybox textarea";

}

?>

<html>
<head>
<title>Script</title>
</head>

<body>
<form name="myform" action="index.php" method="post">

<textarea name="mybox" cols="75" rows="5" wrap="soft">
Data goes here
</textarea>

<input type="checkbox" name="checkbox1" value="checkbox1">
<input type="checkbox" name="checkbox2" value="checkbox2">

<input type="submit" value="Submit" name="submit">

</form>
</body>
</html>

Also, how can I specify that all data should be placed between two pieces of data no matter which checkboxes are selected?

For example:

If both checkboxes are selected, the data from each would always be placed between:

TopData

*data from checkbox1
*data from checkbox2

BottomData

How can I get this to work?

Thanks.

a1call

3:07 am on Feb 3, 2006 (gmt 0)

10+ Year Member



Not tested. $echo.. could be $justaboutanytext


<?php
$echo1='';
$echo2='';
$echo1-2='';
if (isset($_POST['checkbox1'])) {

$echo1= 'echo this javascript data to mybox textarea';

}

if (isset($_POST['checkbox2'])) {
$echo2= 'echo this javascript data to mybox textarea';

}
$echo1-2=$echo1.$echo2;

?>

<html>
<head>
<title>Script</title>
</head>

<body>
<form name="myform" action="index.php" method="post">

<textarea name="mybox" cols="75" rows="5" wrap="soft">
<?php echo($echo1-2);
?>
</textarea>

<input type="checkbox" name="checkbox1" value="checkbox1">
<input type="checkbox" name="checkbox2" value="checkbox2">

<input type="submit" value="Submit" name="submit">

</form>
</body>
</html>


TopData

<?php echo($echo1.'<br>'.$echo2);
?>

BottomData

spyder_tek

9:01 am on Feb 4, 2006 (gmt 0)

10+ Year Member



Thanks! That's exactly what I needed.