I don't have time to actually make the function for you, but I know it could be easily done with a single function and a double for loop, which could go through an two-dimensional array of the questions (first element), answers (next group except last), and the right answer (last element).
basically: $ArrCount = count($Question); for ($Counter = 0; $Counter < $ArrCount; $Counter++) { $Que = $Question[$Counter][0]; $SecArrCount = count($Question[$Counter]); // SecArrCount should be the number equal to the last element (answer) ?><SCRIPT LANGUAGE="Javascript">function CheckAnswer() {var RightAnswer = $Question[$Counter][$SecArrCount]; }</SCRIPT><? for ($AnsCount = 1; $AnsCount < SecArrCount; $AnsCount++): ?><!--Write the HTML code with the PHP variables ($Question[$Counter][$AnsCount]) placed where they're needed--><? endfor; $AnsCount++; } The other loop would then generate a table row kind of like this: <TR..><..TD> <SCRIPT LANGUAGE="Javascript"...> function CheckAnswer(str) { var Answer = <?=$Question[$Counter][$LastElementNum]?> if ( } </SCRIPT...> $Question[$Counter][0]<..BR..><INPUT.. onChange="CheckAnswer(this.value)"> or <SELECT..><options... onClick="CheckAnswer(this.value)"></SELECT..></TD..></TR..> I didn't check to see if any of that stuff worked, but it should give you a basic idea of what I mean. In response to one of your e-mails to me (for some reason I cannot send e-mail right now, but I can post in here): <RE: [PHP] Generating word documents based on fields in a browser> I would think so, and with all of the functions with PHP it might be easier. I had some trouble making up a template language in ASP, but in PHP it would be quite easy because of the vast amount of built-in functions. You might be able to fiddle with the exec(); function to start up programs on a Windows server, but don't take my word for it. "Henning Sittler" <[EMAIL PROTECTED]> wrote in message FBA86B8BA4D6D411BC2A0002B323D39A019408D4@MAIL2">news:FBA86B8BA4D6D411BC2A0002B323D39A019408D4@MAIL2... > Speaking of forms, and I'm sure lots have asked this before me, but anyone > know anywhere I can go to see some examples or existing code for > automatically generating and and validating dynamic forms? > > Wait though, I'm already doing this myself. To explain further, what I > really want is an abstract set of php functions to say, ok, I want another > form with say 10 questions, and I want to define each question and set of > possible answers (input types and ranges) manually, and have the action > script automatically check that the input types and ranges for each question > are valid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php