It doesn’t seem to read the question+$i part.
aka the $_REQUEST in for loop isn’t working too well.
Any suggestions?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Worksheet Creator</title>
<script type="text/javascript">
function add_questions()
{
number = Number(document.getElementById("questions").value);
document.getElementById("numquestions").value = number;
document.getElementById("question_place").innerHTML = "";
for(i=1;i<=number;i++)
{
document.getElementById("question_place").innerHTML += add_question(i)
}
}
function add_question(id)
{
return "Question #"+ id +": <input type='text' id='question"+ id +"'><br>";
}
</script>
</head>
<body>
<form action="makeform.php" method="post">
<table border="1">
<tr>
<td>Title of Worksheet</td>
<td><input type="text" name="title"></td>
</tr>
<tr>
<td>Number of Questions</td>
<td><input type="text" name="questions" id="questions" onBlur="add_questions()"></td>
</tr>
<tr>
<td>Directions</td>
<td><input type="text" name="directions"></td>
</tr>
</table>
<input type="hidden" name="numquestions">
<div id="question_place"></div>
<input type="submit" value="Create Worksheet">
</form>
</body>
</html>
<?
$title = $_REQUEST['title'];
$directions = $_REQUEST['directions'];
$numquestions = $_REQUEST['numquestions'];
$questions = array();
for ($i=1; $i <= $numquestions; $i++)
{
$strn = "question".$i;
$question = $_REQUEST[$strn];
array_push($questions, $question);
echo $i." ----- ".$question." <br>";
}
echo "Question 1:".$questions[1]." TITLE WAS ".$numquestions;
?>