here is my code ajaxtest1.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function  getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}
function  MakeRequest()
{
  var xmlHttp = getXMLHttp();

 xmlHttp.onreadystatechange = function(){
        if(xmlHttp.readyState == 4){
            document.getElementById('myid').innerHTML = xmlHttp.responseText;
        }
    }

 var form1 = document.getElementById('form').value;
var qrystring='?form='+form1;
alert(qrystring);
  xmlHttp.open("GET", "myform.php"+qrystring, true);
  xmlHttp.send(null);
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
<input type="text" id='form' value="conditional.html"/>
<div id='myid' ></div>
<input type='button'  onclick='MakeRequest();' value='Use AJAX!!!!'/>
    <div id='ResponseDiv'>
      This is a div to hold the response.
    </div>

    </form>
</body>
</html>

myform.php
<?php 

 $job=$_GET['form'];
 echo $job;
//echo'<script>window.location=$job</script>'; 
?>

i want to display conditional.html content in new window.along with the values passed from the ajaxtest1.php but nothing is opening .how could i do that?

Member Avatar for diafol

I really don't see the point of the ajax here. I'm confused. You want to get form data from a form that isn't submitted. OK, you can do that, but better to use an 'onsubmit' attribute.

var form1 = document.getElementById('form').value;
var qrystring='?form='+form1;
alert(qrystring);

This is looking for a tag with id 'form' which doesn't seem to exist in your code. Sorry if I've missed it.

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.