WendiT
WendiT

Reputation: 605

form textarea instead of input

I got this code and I want to modify it a bit. It is a form that shows the number of words in a text. I want to change the input (

I have tried many things to use a textarea but either there is no output or the original text disappears. Changing the name into id didn't work, same for the 'normal way of using a textarea'.

Is there a way of doing of replacing the input with textarea? One thing that has to stay is that after a submit the text in the textarea needs to be visible.

I appreciate any help.

<?php
error_reporting(0);
$inputtext = $_POST['ipt'];


if ($_POST['clear']) {
    $inputtext   = "";
    $output1 = "";
}

if ($_POST['send']) {
    $output1 = "Number of words in this text: " . str_word_count($inputtext);
}
?>
<html>
<head>
<style>
body {
font-family:arial;
font-size:12px
}

.bigtextarea {
width:100%;
height:40%;
min-height:200px
}

textarea {
font-family:monospace;
border-color:#a9a9a9
}
</style>
</head>

<title>Form results on one page after submit</title>
<body>
<form action="" method="POST">
  <h1>Form results on one page after submit</h1>
  <h3>Copy and Paste text:</h3>
  <input class="bigtextarea" wrap="hard" type= textarea name=ipt value="<?php echo $inputtext;?>" height="100px" size="100%">
  <input type="submit" name="send" value="Ok" title="Click here to display values.">
  <input type="submit" name="clear" value="Clear" title="Click here to clear text boxes.">
</form>
<?php
echo "<br><br>";
echo "<font size='4'>";
echo $output1;
echo "</font>";
?>
</body>
</html>

Upvotes: 1

Views: 2943

Answers (1)

Niraeth
Niraeth

Reputation: 313

<input class="bigtextarea" wrap="hard" type= textarea name=ipt
value="<?php echo $inputtext;?>" height="100px" size="100%">

Replace with

<textarea name="ipt" class="bigtextarea" wrap="hard"><?php echo $inputtext ?></textarea>

Upvotes: 1

Related Questions