I have two table on the page, call Ajax after hiding one, and then use HTML to spell another table, the results of the new table has a undefined, how this is caused, how to solve it? The detailed code is as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
$ (function () {
if ($.browser.msie)
{
$ ("#country"). Get (0). attachevent ("Onpropertychange", Function (o) {
var countr = O.srcelement.value;
$ ("#tabb1"). Hide ();
$.ajax ({
Type: "Post",
URL: "/yoblhtjfx/querycountryajax.action",
Data: "country=" +countr+ "&jsoncallback=?",
DataType: "JSON",
Success:function (JSON)
{
var tablehtml;
tablehtml+= "<table id= ' tabb1 ' border= ' 1 ' width= ' 100% ' >";
tablehtml+= "<tr>";
tablehtml+= "<td style= ' Text-align:center ' > Selection </td>";
tablehtml+= "<td style= ' text-align:center ' > Area code </td>";
tablehtml+= "<td style= ' Text-align:center ' > Country name </td>";
tablehtml+= "</tr>";
var list = Json.list;
for (Var i=0;i<list.length;i++)
{
tablehtml+= "<tr>";
tablehtml+= "<td style= ' text-align:center ' ><input type= ' radio ' name= ' radioo ' ' value= '" +list[i][1]+ ' "/>" </td> ";
tablehtml+= "<td style= ' Text-align:center ' >" +list[i][0]+ "</td>";
tablehtml+= "<td style= ' Text-align:center ' >" +list[i][1]+ "</td>";
tablehtml+= "</tr>";
}
tablehtml+= "</table>";
$ ("#querycountrydiv"). HTML (tablehtml);
}
});
});
}
});
function ReturnVal ()
{
var Valu;
for (var i = 0;i < Document.getelementsbyname ("Radioo"). length;i++)
{
if (Document.getelementsbyname ("Radioo") [i].checked = = True)
{
Valu = Document.getelementsbyname ("Radioo") [I].value;
}
}
Window.opener.document.getElementById ("Foreignunitcountry"). Value = Valu;
Window.close ();
}
</script>
<body>
<div align= "center" style= "width:100%;" >
Enter Name search:
Copy Code code as follows:
<input id= "Country" name= "Country" "value=" ">
</div>
<HR id= "hr"/>
<div id= "Querycountrydiv" name= "Querycountrydiv" style= "width:100%"; height:80%; Overflow:auto; border:1px solid #000000; " >
<table id= "TABB1" border= "1" width= "100%" >
<tr>
<TD style= "Text-align:center" nowrap= "nowrap" > Selection </td>
<TD style= "Text-align:center" nowrap= "nowrap" > Area code </td>
<TD style= "Text-align:center" nowrap= "nowrap" > Country name </td>
</tr>
<c:foreach items= "${list}" var= "List" >
<tr>
<TD style= "Text-align:center" nowrap= "nowrap" ><input type= "Radio" name= "Radioo" value= "${list[1]}"/> </td>
<TD style= "Text-align:center" nowrap= "nowrap" >${list[0]}</td>
<TD style= "Text-align:center" nowrap= "nowrap" >${list[1]}</td>
</tr>
</c:forEach>
</table>
</div><br>
<HR id= "hr"/>
<div>
<input id= "button" type= "button" value= "to determine" onclick= "returnval ();"/>
<input id= "button" type= "button" value= "closes" onclick= "window.close ();"/>
</div>
</body>
Is that a section of code in the above code has a syntax error, as follows is a modified code snippet:
Success:function (JSON) {
var tablehtml = ";
...