I tried out a form to collect sentences. Works well, BUT: 1 student pressed enter in the textarea number 18
This pushed all his answers down 1 line and his score was very bad.
<textarea cols="26" rows="1" maxlength="26" placeholder="Write your answer here." name="G18"></textarea>
Apparently, setting rows=“1” does not prevent the use of ‘enter’ in a textarea like I hoped.
I’m wondering if it is possible to look at each php variable before they get sent and get rid of new line characters?
This code, kindly suggested to me here puts an X in empty variables
if($studentnr == '') {$studentnr = 'X';}
for ($i=1; $i <= 35; $i++) {
if (${"q$i"} == '') ${"q$i"} = 'X';
}
Maybe something similar can get rid of newline characters? Thanks for any tips or links!
Edit: I tried this, it seems to work. Can it be tidied up a bit?
for ($i=1; $i <= 35; $i++) {
$str = ${"q$i"};
$order = array("\r\n", "\n", "\r");
$nonewlines = str_replace($order, '', $str);
${"q$i"} = $nonewlines;
}