表单textarea而不是输入

时间:2018-04-26 02:38:05

标签: php html forms textarea

我有这个代码,我想稍微修改一下。它是一个显示文本中单词数量的表单。我想改变输入(

我尝试了很多东西来使用textarea,但是没有输出或原始文本消失。将名称更改为id不起作用,对于“使用textarea的常规方式”也是如此。

有没有办法用textarea替换输入?必须留下的一件事是,在提交后,textarea中的文本需要可见。

我感谢任何帮助。

<?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>

1 个答案:

答案 0 :(得分:1)

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

替换为

  

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

相关问题