I want to be able to access whatever the user types into my testCreation.html in a session created in testCheck.php. I then want that session to be accessed by testView.php. I can't seem to get to that point so any help is grealy appreciated.

testCreation.html:

<html xmlns="http://www.w3.org/1999/xhtml" >

 <head runat="server">

   <title>Untitled Page</title>

   <script type="text/javascript">

     var questionNum = 1;


     function include(file) {
        if (document.createElement && document.getElementsByTagName) {
          var head = document.getElementsByTagName('head')[0];

          var script = document.createElement('script');
          script.setAttribute('type', 'text/javascript');
          script.setAttribute('src', file);

          head.appendChild(script);
        }

        else {
          alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
        }
      }


     function includes()
     {
     include("testCheck.php");
     }


     function addQuestion()
     {
      var paragraph = document.createElement("p");
      document.getElementById("divRadiolist").appendChild(paragraph);


      var newQuestion = document.createTextNode(questionNum + ". \n");
      document.getElementById("divRadiolist").appendChild(newQuestion);


      document.getElementById("divRadiolist").appendChild(paragraph);


      var myText = document.createElement("input");
      myText.id = "text" + questionNum;
      myText.setAttribute("type", "text");
      myText.setAttribute("name", "question"+questionNum);
      myText.style.width = "1000px";
      myText.style.height = "25px";
      document.getElementById("divRadiolist").appendChild(myText);

      questionNum++;
    }

  </script>

  </head>

<body>

  <form id="form1" action="testView.php" method="post">
  <input type="button" id="btnAddQuestion" value="Create Question" onclick="addQuestion()" />
  <div id="divRadiolist"></div>
  <p><input type="submit" name="submitted" value="Save Test"  onclick="includes()"/></p>

  </form>

</body>

</html>

testCheck.php:

<?php

     $questionNum = 1;
     session_start();
     $_SESSION['question']=$_POST["question"+$questionNum];


?>

testView.php:

<?php
 session_start();
?>
  <html>
  <head>
  <title>-</title>
  </head>

<body>

      <?php
            $question = $_SESSION['question'];
            echo "<p>Hi and {$question}.</p>";

      ?>

</body>

</html>

Kind Regards,
Towlie.

Hi,

You can use jquery.

To create an element: $("<input type=text name='whatever' id='whatever' value='whatever'/>").appendTo("#form_id"); To set an event to whatever:

//Change
//Note that you can have a button to send the information
$("#whatever").change(
function(){
 var answer=$(this).val();
 $.ajax({		    		   
    url: 'http://yoururl?answer_value='+answer,
    success: function(data) {
       alert("Success");
    }
  );
}
);

Please note that to catch the value in php you have to use the $_GET or $_REQUEST instead he $_POST

Visit: http://jquery.com/

If you start you will never stop. That will help you make wonderful things and its very easy to that.

Best Regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.