The IF statement checks if a string is empty. If not empty a hyperlink appears on a popup DIV, otherwise the hyperlink should be omitted.
I have attached a piece of cut down code to illustrate the problem.
Follow these steps:
1. Clicking on link A displays a DIV with only a "Close this window" link.
2. Clicking on link B displays a DIV with an "Attached document" link as well as the "Close this window" link.
3. Clicking on link A again displays a DIV with both links where I would only expect the "Close this window" link to appear as the length of arrayObj[1][5] = "".
<html>
<head>
<SCRIPT language= javascript >
var arrayObj = new Array(5);
for (i = 0; i < 3; i++)
arrayObj = new Array(5)
arrayObj[1][0] = 1;
arrayObj[1][1] = "Link A";
arrayObj[1][2] = "AA";
arrayObj[1][3] = "AA";
arrayObj[1][4] = "AA";
arrayObj[1][5] = "";
arrayObj[2][0] = 2;
arrayObj[2][1] = "Link B";
arrayObj[2][2] = "BB";
arrayObj[2][3] = "BB";
arrayObj[2][4] = "BB";
arrayObj[2][5] = "BB";
function DisplayDiv(ID)
{
td4.innerHTML = arrayObj[ID][4] + '<br><br>';
alert("String length = " + arrayObj[ID][5].length);
// THIS IF STATEMENT IS INCONSISTENT
if (arrayObj[ID][5].length != 0)
td5.innerHTML = "<a href = 'abc.asp' target='_new'>Attached document</a><br><br>";
document.all.DivPopUp.style.visibility = "visible";
}
function HideDiv()
{
document.all.DivPopUp.style.visibility = "hidden";
}
</SCRIPT>
</head>
<body>
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="textBlackSmall">
<tr>
<td><a href="javascript:void[0]" onclick="DisplayDiv(1)">A</a></td>
</tr>
<tr >
<td><a href="javascript:void[0]" onclick="DisplayDiv(2)">B</a></td>
</tr>
</table>
<div id="DivPopUp" style="position:absolute; left : 200px; width : 420px; visibility : hidden; background-color: #ffffcc; " >
<table width = 400 align = "center" border = 0>
<tr valign = "top">
<td width = 15%><b>Details: </b></td>
<td colspan = 3><div id = 'td4' style="position: relative; width: 320px; height: 100px; background-color: #ffffff; overflow: auto "> </div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan = 4 align = "center" id = "td5"> </td>
</tr>
<tr>
<td colspan=4 align=center><a href="javascript:void[0]"onclick='HideDiv()'>Close this window </td>
</tr>
</table>
</div>
</body>
</html>
I have attached a piece of cut down code to illustrate the problem.
Follow these steps:
1. Clicking on link A displays a DIV with only a "Close this window" link.
2. Clicking on link B displays a DIV with an "Attached document" link as well as the "Close this window" link.
3. Clicking on link A again displays a DIV with both links where I would only expect the "Close this window" link to appear as the length of arrayObj[1][5] = "".
<html>
<head>
<SCRIPT language= javascript >
var arrayObj = new Array(5);
for (i = 0; i < 3; i++)
arrayObj = new Array(5)
arrayObj[1][0] = 1;
arrayObj[1][1] = "Link A";
arrayObj[1][2] = "AA";
arrayObj[1][3] = "AA";
arrayObj[1][4] = "AA";
arrayObj[1][5] = "";
arrayObj[2][0] = 2;
arrayObj[2][1] = "Link B";
arrayObj[2][2] = "BB";
arrayObj[2][3] = "BB";
arrayObj[2][4] = "BB";
arrayObj[2][5] = "BB";
function DisplayDiv(ID)
{
td4.innerHTML = arrayObj[ID][4] + '<br><br>';
alert("String length = " + arrayObj[ID][5].length);
// THIS IF STATEMENT IS INCONSISTENT
if (arrayObj[ID][5].length != 0)
td5.innerHTML = "<a href = 'abc.asp' target='_new'>Attached document</a><br><br>";
document.all.DivPopUp.style.visibility = "visible";
}
function HideDiv()
{
document.all.DivPopUp.style.visibility = "hidden";
}
</SCRIPT>
</head>
<body>
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="textBlackSmall">
<tr>
<td><a href="javascript:void[0]" onclick="DisplayDiv(1)">A</a></td>
</tr>
<tr >
<td><a href="javascript:void[0]" onclick="DisplayDiv(2)">B</a></td>
</tr>
</table>
<div id="DivPopUp" style="position:absolute; left : 200px; width : 420px; visibility : hidden; background-color: #ffffcc; " >
<table width = 400 align = "center" border = 0>
<tr valign = "top">
<td width = 15%><b>Details: </b></td>
<td colspan = 3><div id = 'td4' style="position: relative; width: 320px; height: 100px; background-color: #ffffff; overflow: auto "> </div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan = 4 align = "center" id = "td5"> </td>
</tr>
<tr>
<td colspan=4 align=center><a href="javascript:void[0]"onclick='HideDiv()'>Close this window </td>
</tr>
</table>
</div>
</body>
</html>