Jump to content

How do I implement textboxes?


w3bbi3

Recommended Posts

Hi,

 

I need a textbox to be placed under each question, too. How do I do that using the code, by lococobra, below?

 

<?php>
$content = 'How do I implement textboxes under each question?  Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well?

';

preg_match_all('/(?<=[.?!]|^).*?(?=([.?!]).{0,3}[A-Z]|$)/s',$content,$matches);
echo "<pre>";
for($i=0;$i<count($matches[0]);$i++)
   $result[] = trim($matches[0][$i]).$matches[1][$i];
print_r($result);
?>

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/206467-how-do-i-implement-textboxes/
Share on other sites

Perhaps this...

<?PHP

$content = "How do I implement textboxes under each question? Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well?";
$question_array = explode($content"?",);
$num_q = count($question_array);
$i=0;
while($i<$num_q) {
echo $question_array[$i] . "<br>";
?>
<textarea name="variablename<?PHP echo $i; ?>" rows="3" cols="40"></textarea>
<?PHP
$i++;
}
?>

If you want to use your original code:

<?php
$content = 'How do I implement textboxes under each question?  Do you know how to insert a textbox under this question, too? How about this one? Any clue on how to get a textbox to show up with a textbox underneath this one as well?

';

preg_match_all('/(?<=[.?!]|^).*?(?=([.?!]).{0,3}[A-Z]|$)/s',$content,$matches);
for($i=0;$i<count($matches[0]);$i++)
   $result[] = trim($matches[0][$i]).$matches[1][$i];
?>

<form action="" method="">
<?php
for($i=0;$i<count($result);$i++)
{
echo "<p>".($i+1).") {$result[$i]}<br/>";
//echo '<input type="text" name="answer'.($i+1).'"/></p>';
echo "<textarea></textarea></p>";
}
?>

Adjust html to fit your needs.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.