Итак, у меня есть этот код:
<?php
if(isset($_POST['submit']))
{
$input = $_POST['input'];
$writeinput = fopen('editedtext.txt', 'w');
fwrite($writeinput, $input);
}
?>
<body>
<form method="post">
<textarea name="input" id="input"><?php $data = file_get_contents('editedtext.txt'); echo $data;?></textarea>
<button name="submit">Submit</button>
<div style="background-color: white; height: 200px;" id="output-div-display">
<output name="display-result">
<div style="background-color: white;" id="div-output-white"><?php include 'editedtext.txt';?></div>
</output>
</div>
</form>
</body>
<style>
body
{
background-color: #404040;
}
#input
{
width: 100%;
height: 200px;
}
#output-div-display, #div-output-white
{
background-color: white;
}
button
{
width: 100%;
height: 30px;
}
</style>
<script>
var outputHeight = document.getElementById('div-output-white').style.height;
if(outputHeight<200)
{
document.getElementById('output-div-display').style.height = 200;
}
if(outputHeight===200)
{
document.getElementById('output-div-display').style.height = 200;
}
if(outputHeight>200)
{
document.getElementById('output-div-display').style.height = outputHeight;
}
</script>
Это работает хорошо, но если я наберу <textarea></textarea>
внутри текстовой области ( input ) и дважды нажму кнопку подтверждения, код перерывается.
Это происходит при первом щелчке отправки
И это происходит при втором щелчке
Код также перестает работать, случается когда я использую <form></form>
в качестве значения input . Помогите пожалуйста ..