0

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?

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
5
Views
7 Years
Discussion Span
Last Post by diafol
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.