473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

using <div> inside <form>

hi ,
Iam Nagesh,Begineer in using Ajax,well

i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag
iam able to get the response in the <div> tag in mozilla (im takingthe HTML response),
<script>
function confirm()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="confirm.jsp";
url=url+"?q="+document.login.id.value;
//url=url+"&sid="+Math.random();
url=url+"&p="+document.login.pwd.value;
//url=url+"&pid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert("hi");
//var message = xmlHttp.responseXML.getElementsByTagName("message" )[0].childNodes[0].data;
//alert(message);
alert("everone");
alert(xmlHttp.responseText);
var response=xmlHttp.responseText;
document.getElementById("hema").innerHTML=response ;
alert(xmlHttp.responseText);
alert("Hi in state changed");

}
<script>

and the form iam using in the <body> is

<form name="login">

<table align="center" >
<tr>
<td><b>UserId:</b></td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="pwd"></td>
</tr>
</table>
<div align="center">
<p><input type="button" value="Login" onclick="confirm()"></p>
</div>

<div>
<p>For Registration Click Here&nbsp;&nbsp;<input type="button" value="Register" onclick="register()"></p>
</div>
<div id="hema"></div>
</form>


so the issue is that i will get the html response in the script that should be displayed in the <div id="hema"> tag.

It is working in mozilla but not in IE, any answers.., thanks
Jul 4 '07 #1
10 14113
praveen2gupta
201 100+
hi ,
Iam Nagesh,Begineer in using Ajax,well

i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag
iam able to get the response in the <div> tag in mozilla (im takingthe HTML response),
<script>
function confirm()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="confirm.jsp";
url=url+"?q="+document.login.id.value;
//url=url+"&sid="+Math.random();
url=url+"&p="+document.login.pwd.value;
//url=url+"&pid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert("hi");
//var message = xmlHttp.responseXML.getElementsByTagName("message" )[0].childNodes[0].data;
//alert(message);
alert("everone");
alert(xmlHttp.responseText);
var response=xmlHttp.responseText;
document.getElementById("hema").innerHTML=response ;
alert(xmlHttp.responseText);
alert("Hi in state changed");

}
<script>

and the form iam using in the <body> is

<form name="login">

<table align="center" >
<tr>
<td><b>UserId:</b></td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="pwd"></td>
</tr>
</table>
<div align="center">
<p><input type="button" value="Login" onclick="confirm()"></p>
</div>

<div>
<p>For Registration Click Here&nbsp;&nbsp;<input type="button" value="Register" onclick="register()"></p>
</div>
<div id="hema"></div>
</form>


so the issue is that i will get the html response in the script that should be displayed in the <div id="hema"> tag.

It is working in mozilla but not in IE, any answers.., thanks

Hi

You are using only one Object which is not supported By IE. after
Line instead of this xmlHttp=GetXmlHttpObject(); use following

var xmlHttp= false;

if (window.XMLHttpRequest)
{
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");

}

Try This One , your problem must be solved.
Jul 4 '07 #2
Hi

You are using only one Object which is not supported By IE. after
Line instead of this xmlHttp=GetXmlHttpObject(); use following

var xmlHttp= false;

if (window.XMLHttpRequest)
{
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");

}

Try This One , your problem must be solved.



Thanks for ur reply,

well it didnt solve my problem ,the thing is i need to put the HTML page response in the <div> tag with id="hema",i need to get the html page from registration.jsp(this is the page to which im sending url and geting the response),where as i m getting it to be "undefined" after changing the code as u have suggested.in both mozilla n IE.,

iam posting the function named stateChanged():::
function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert(xmlHttp.responseText);
var response=xmlHttp.responseHTML;
document.getElementById("hema").innerHTML=response ;
alert(xmlHttp.responseText);
alert("Hi in state changed");

}
}

im able to get the html content with tags int he var response in the above function but im unable to put the html into the div as mentioned befor,what is the possible way in which i can display the html content in the response as the
html page inside the <div id="hema">,
waiting 4 suggestion..
thanq..
Jul 4 '07 #3
epots9
1,351 Expert 1GB
Thanks for ur reply,

well it didnt solve my problem ,the thing is i need to put the HTML page response in the <div> tag with id="hema",i need to get the html page from registration.jsp(this is the page to which im sending url and geting the response),where as i m getting it to be "undefined" after changing the code as u have suggested.in both mozilla n IE.,

iam posting the function named stateChanged():::
function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert(xmlHttp.responseText);
var response=xmlHttp.responseHTML;
document.getElementById("hema").innerHTML=response ;
alert(xmlHttp.responseText);
alert("Hi in state changed");

}
}

im able to get the html content with tags int he var response in the above function but im unable to put the html into the div as mentioned befor,what is the possible way in which i can display the html content in the response as the
html page inside the <div id="hema">,
waiting 4 suggestion..
thanq..
try this:
Expand|Select|Wrap|Line Numbers
  1. function stateChanged() 
  2. if (xmlHttp.readyState==4)
  3. alert(xmlHttp.responseText);
  4. var response=xmlHttp.responseText; // u had responseHTML
  5. document.getElementById("hema").innerHTML=response;
  6. alert(xmlHttp.responseText);
  7. alert("Hi in state changed");
  8.  
  9. }
  10. }
  11.  
good luck
Jul 4 '07 #4
try this:
Expand|Select|Wrap|Line Numbers
  1. function stateChanged() 
  2. if (xmlHttp.readyState==4)
  3. alert(xmlHttp.responseText);
  4. var response=xmlHttp.responseText; // u had responseHTML
  5. document.getElementById("hema").innerHTML=response;
  6. alert(xmlHttp.responseText);
  7. alert("Hi in state changed");
  8.  
  9. }
  10. }
  11.  

good luck

Yeah it worked fine, Thanks praveen2gupta and epots9..,
Jul 5 '07 #5
praveen2gupta
201 100+
hi ,
Iam Nagesh,Begineer in using Ajax,well

i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag
iam able to get the response in the <div> tag in mozilla (im takingthe HTML response),
<script>
function confirm()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="confirm.jsp";
url=url+"?q="+document.login.id.value;
//url=url+"&sid="+Math.random();
url=url+"&p="+document.login.pwd.value;
//url=url+"&pid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
alert("hi");
//var message = xmlHttp.responseXML.getElementsByTagName("message" )[0].childNodes[0].data;
//alert(message);
alert("everone");
alert(xmlHttp.responseText);
var response=xmlHttp.responseText;
document.getElementById("hema").innerHTML=response ;
alert(xmlHttp.responseText);
alert("Hi in state changed");

}
<script>

and the form iam using in the <body> is

<form name="login">

<table align="center" >
<tr>
<td><b>UserId:</b></td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="pwd"></td>
</tr>
</table>
<div align="center">
<p><input type="button" value="Login" onclick="confirm()"></p>
</div>

<div>
<p>For Registration Click Here&nbsp;&nbsp;<input type="button" value="Register" onclick="register()"></p>
</div>
<div id="hema"></div>
</form>


so the issue is that i will get the html response in the script that should be displayed in the <div id="hema"> tag.

It is working in mozilla but not in IE, any answers.., thanks

Hi
in place of line
if (xmlHttp.readyState==4)

try following line

if (xmlHttp.readyState == 4 && xmlHttp.status == 200)

I think your problem may solve
Jul 5 '07 #6
HI, im using the below code, where iam dispalying the HTML in the div tag named "hello" which is inside the <form>
code inside the function statedChanged()
var response=xmlHttp.responseText;
document.getElementById("hello").innerHTML=respons e;

<body>
<form>
<div id="hello">
</div>
</body>


Iam able to view the html page in the div tag in mozilla,but iam unable to view it in IE, any suggestions are invited..,Thanks...
Jul 5 '07 #7
acoder
16,027 Expert Mod 8TB
I've merged the threads. If it's the same problem, keep it in one thread.
Jul 5 '07 #8
Hi
in place of line
if (xmlHttp.readyState==4)

try following line

if (xmlHttp.readyState == 4 && xmlHttp.status == 200)

I think your problem may solve

i did that but no use, its the same problem, it is giving, "Unknown Run time Error" in the script, unable unable to put response html page in the <div> tag located inside <form> tag..,any other ways??
Jul 5 '07 #9
praveen2gupta
201 100+
i did that but no use, its the same problem, it is giving, "Unknown Run time Error" in the script, unable unable to put response html page in the <div> tag located inside <form> tag..,any other ways??

Hi

you are using two functions in the javascript. I am enclosing an sample code using one function. Try to fit in your code. This is tested sample program

Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript">
  2. var HttpObj = false;
  3.     if (window.XMLHttpRequest) 
  4.     {
  5.         HttpObj = new XMLHttpRequest();
  6.     } 
  7.     else if (window.ActiveXObject) 
  8.     {
  9.         HttpObj = new ActiveXObject("Msxml2.XMLHTTP");
  10.  
  11.     }
  12. function getData()
  13.     {
  14.         if(HttpObj) 
  15.         {
  16.     HttpObj.open("GET", "Fw_Text7.jsp",true);
  17.     HttpObj.onreadystatechange = function()
  18.             {
  19.                 if (HttpObj.readyState == 4 && HttpObj.status == 200) 
  20.                 {
  21. document.getElementById("targetDiv").innerHTML = HttpObj.responseText;
  22.  
  23.                 }
  24.             }
  25.             HttpObj.send(null);
  26.         }
  27.     }
  28. </script>
  29. </head>
  30. <body>
  31. <H1>Fetching data with Ajax</H1>
  32. <form>
  33. <input type="button" value="Display Message" onmouseover='getData()'>
  34.  
  35. </form>
  36.  
  37. <div id="targetDiv">
  38. <p>The fetched data will go here.</p>
  39. </div>
  40. </body>
  41. </html>
  42.  

when mouse is moved over. function getData is called and file Fw_Text7.jsp is called by server and page Response is placed in the div named "targetDiv"
.complete code is on one page using one function. Adjust as per your needs of program
Jul 5 '07 #10
Hi

you are using two functions in the javascript. I am enclosing an sample code using one function. Try to fit in your code. This is tested sample program

Expand|Select|Wrap|Line Numbers
  1. <script language = "javascript">
  2. var HttpObj = false;
  3.     if (window.XMLHttpRequest) 
  4.     {
  5.         HttpObj = new XMLHttpRequest();
  6.     } 
  7.     else if (window.ActiveXObject) 
  8.     {
  9.         HttpObj = new ActiveXObject("Msxml2.XMLHTTP");
  10.  
  11.     }
  12. function getData()
  13.     {
  14.         if(HttpObj) 
  15.         {
  16.     HttpObj.open("GET", "Fw_Text7.jsp",true);
  17.     HttpObj.onreadystatechange = function()
  18.             {
  19.                 if (HttpObj.readyState == 4 && HttpObj.status == 200) 
  20.                 {
  21. document.getElementById("targetDiv").innerHTML = HttpObj.responseText;
  22.  
  23.                 }
  24.             }
  25.             HttpObj.send(null);
  26.         }
  27.     }
  28. </script>
  29. </head>
  30. <body>
  31. <H1>Fetching data with Ajax</H1>
  32. <form>
  33. <input type="button" value="Display Message" onmouseover='getData()'>
  34.  
  35. </form>
  36.  
  37. <div id="targetDiv">
  38. <p>The fetched data will go here.</p>
  39. </div>
  40. </body>
  41. </html>
  42.  

when mouse is moved over. function getData is called and file Fw_Text7.jsp is called by server and page Response is placed in the div named "targetDiv"
.complete code is on one page using one function. Adjust as per your needs of program

yeah it worked out, i made a mistake ,where im requesting to the jsp in which the fileds are in <form> tag and iam trying to put the response in the <form> tag agian, ie(indirectly im putting <form> inside another <form>)which is not suported in IE,ths the mistake i have ,done ,thankyou for ur help guyz...
Jul 6 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: F. Da Costa | last post by:
Following is a snippet of html in which I hide a whole table and try to hide a single row. Here is my question (plz don't chew my head off if its css related instead): Why does the divTable...
55
by: Ton den Hartog | last post by:
Stupid basic question but I find it horribly imposible to find the answer elsewhere... :-( I want to have a piece of text in my HTML page and want to be able to change it in a Javascript...
14
by: Charlie T | last post by:
Hello, is there any way to get this to work? myID.innerHTML = "Hello" <DIV id="myID"></DIV> <DIV id="myID"></DIV>
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
2
by: ad | last post by:
When we create a new aspx in VS.Net, it will insert <div> tag inside <form> tag, like below. What is the function of <div> do?...
11
by: News | last post by:
Here is the form and div snippet <form <form name="myForm"> <div id="myDiv"> { background-color: #9900FF; } </div> </form>
1
by: alanchinese | last post by:
let's say i have codes like this: <form> <div> <input type="text" name="in1" size="10"> <input type="text" name="in2" size="100"> <!-- more inputs --> </div> <form> can javascript calculate...
5
by: Vear | last post by:
Hi, I have several <Div>'s that I have assigned an ID for. When the page loads It set the Absolute Position through a Style sheet. Can I then reference the <Div> through VB to move it to another...
6
by: plumba | last post by:
Hi I have a check box which when ticked displays the sumit buttons of a form and gives the checkbox field a value of "agree". I would like to set the check box to hide the section of the form...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.