使用< div>里面< form> [英] using <div> inside <form>

查看:86
本文介绍了使用< div>里面< form>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Iam Nagesh,Begineer使用Ajax,好吧


i一直在应用程序中使用ajax,我在放置responseTEXT时遇到了问题进入< div>标签位于< form>内标签

我能够在< div>中获得响应mozilla中的标签(我正在接受HTML回复),

< script>

功能确认()

{

xmlHttp = GetXmlHttpObject();

if(xmlHttp == null)

{

alert("您的浏览器不支持AJAX! );

返回;

}

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);

}


函数stateChanged()

{

if (xmlHttp.readyState == 4)

{

alert(" hi");

// var message = xmlHttp.responseXML。 getElementsByTagName(" message")[0] .childNode s [0] .data;

// alert(消息);

alert(" everone");

alert(xmlHttp。 responseText);

var response = xmlHttp.responseText;

document.getElementById(" hema")。innerHTML = response;

alert( xmlHttp.responseText);

alert(" Hi in state changed");


}

< script>


和iam在< body>中使用的形式


< form name =" login">


< table align =" center" >

< tr>

< td>< b> UserId:< / b>< / td>

< td>< input type =" text" name =" id">< / td>

< / tr>

< tr>

< td> < b>密码< / b>< / td>

< td>< input type =" password" name =" pwd">< / td>

< / tr>

< / table>

< div align =" center">

< p>< input type =" button"值= QUOT;登录" onclick =" confirm()">< / p>

< / div>


< div>

< p>注册点击此处& nbsp;& nbsp;< input type =" button"值= QUOT;注册" onclick =" register()">< / p>

< / div>

< div id =" hema">< / div>

< / form>


所以问题是我会在脚本中得到应该显示的html响应在< div id =" hema">中标签。


它在mozilla工作但不在IE中,任何答案..,谢谢

解决方案




Iam Nagesh,Begineer使用Ajax,好吧


i在应用程序中使用ajax,我遇到过将responseTEXT放入< div>时出现问题标签位于< form>内标签

我能够在< div>中获得响应mozilla中的标签(我正在接受HTML回复),

< script>

功能确认()

{

xmlHttp = GetXmlHttpObject();

if(xmlHttp == null)

{

alert("您的浏览器不支持AJAX! );

返回;

}

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);

}


函数stateChanged()

{

if (xmlHttp.readyState == 4)

{

alert(" hi");

// var message = xmlHttp.responseXML。 getElementsByTagName(" message")[0] .childNode s [0] .data;

// alert(消息);

alert(" everone");

alert(xmlHttp。 responseText);

var response = xmlHttp.responseText;

document.getElementById(" hema")。innerHTML = response;

alert( xmlHttp.responseText);

alert(" Hi in state changed");


}

< script>


和iam在< body>中使用的形式


< form name =" login">


< table align =" center" >

< tr>

< td>< b> UserId:< / b>< / td>

< td>< input type =" text" name =" id">< / td>

< / tr>

< tr>

< td> < b>密码< / b>< / td>

< td>< input type =" password" name =" pwd">< / td>

< / tr>

< / table>

< div align =" center">

< p>< input type =" button"值= QUOT;登录" onclick =" confirm()">< / p>

< / div>


< div>

< p>注册点击此处& nbsp;& nbsp;< input type =" button"值= QUOT;注册" onclick =" register()">< / p>

< / div>

< div id =" hema">< / div>

< / form>


所以问题是我会在脚本中得到应该显示的html响应在< div id =" hema">中标签。


它在mozilla工作但不在IE中,任何答案..,谢谢



你好

您只使用一个IE不支持的对象。之后

行而不是这个xmlHttp = GetXmlHttpObject();使用以下


var xmlHttp = false;


if(window.XMLHttpRequest)

{

xmlHttp = new XMLHttpRequest();

}

else if(window.ActiveXObject)

{

xmlHttp = new ActiveXObject(" Msxml2.XMLHTTP");


}


尝试这一个,你的问题必须解决。






您只使用一个IE不支持的对象。之后

行而不是这个xmlHttp = GetXmlHttpObject();使用以下


var xmlHttp = false;


if(window.XMLHttpRequest)

{

xmlHttp = new XMLHttpRequest();

}

else if(window.ActiveXObject)

{

xmlHttp = new ActiveXObject(" Msxml2.XMLHTTP");


}


尝试这一个,你的问题必须解决。




感谢您的回复,


它没有解决我的问题,事情我需要将HTML页面响应放在< div>中使用id =" hema"的标签,我需要从registration.jsp获取html页面(这是我发送网址和确定响应的页面),其中我将其设为未定义在改变你建议的代码之后。在mozilla n IE中。


iam发布名为stateChanged()的函数:::

函数stateChanged(如果(xmlHttp.readyState == 4)

{

alert(xmlHttp.responseText) ;

var response = xmlHttp.responseHTML;

document.getElementById(" hema")。innerHTML = response;

alert(xmlHttp。 responseText);

alert(" Hi in state changed");


}

}


能够在上面的函数中使用标签获取带有变量响应的html内容但是我无法将html放入div中,如上所述,我可以用什么方式显示html内容在响应中作为

html页面内< div id =" hema">,

等待4个建议..

thanq ..



比你回复的ks,


它没有解决我的问题,我需要将HTML页面响应放在< div>中使用id =" hema"的标签,我需要从registration.jsp获取html页面(这是我发送网址和确定响应的页面),其中我将其设为未定义在改变你建议的代码之后。在mozilla n IE中。


iam发布名为stateChanged()的函数:::

函数stateChanged(如果(xmlHttp.readyState == 4)

{

alert(xmlHttp.responseText) ;

var response = xmlHttp.responseHTML;

document.getElementById(" hema")。innerHTML = response;

alert(xmlHttp。 responseText);

alert(" Hi in state changed");


}

}


能够在上面的函数中使用标签获取带有变量响应的html内容但是我无法将html放入div中,如上所述,我可以用什么方式显示html内容在响应中作为

html页面内< div id =" hema">,

等待4个建议..

thanq ..



试试这个:

展开 | 选择 | Wrap | 行号

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 ,
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.


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..


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


这篇关于使用&lt; div&gt;里面&lt; form&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆