Hello guys
i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in mozilla perfectly but not in IE.
To check where is the fault i have written so many alert() but sometimes these are working.
Please someone read my code and tell me why its not working.
i am also sending you the function validateIPandNe tMask()
my alert statement is commented so that one can understand my code
[CODE=javascript]var enteredip;
function validateIPandNe tMask()
{
enteredip=docum ent.addform.ipa ddress.value
firstvalue=docu ment.addform.ip address.value;
//alert("fstvalue ="+firstvalu e)
ipnetmaskarr=fi rstvalue.split( "/");
ip=ipnetmaskarr[0];
nm=ipnetmaskarr[1];
//alert("ipnetmas k0="+ipnetmaska rr[0]+"ipnetmask1="+ ipnetmaskarr[1]);
if(ipnetmaskarr[1]==null)
{
if(validateIPAd dress(ipnetmask arr[0]))
{
if(isBrowserIE( ))
{
window.returnva lue=addform.use rid.value+'/'+addform.ipadd ress.value;
}
else
{
opener.document .viewform.useri d.value=documen t.addform.useri d.value;
opener.document .viewform.ipadd ress.value = firstvalue;
opener.document .viewform.mode. value = "<%=FWBMModes.A DD%>";
opener.document .viewform.submi t();
}
self.close();
}
else
{
alert("Enter a valid IP Address before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
else
{
//alert("ip= "+ip+" nm="+nm);
if(validateIPAd dress(ipnetmask arr[0]))
{
if(validateIPNe tmask(ipnetmask arr[1]))
{
if(isBrowserIE( ))
{
window.returnva lue=addform.use rid.value+'/'+addform.ipadd ress.value;
}
else
{
//alert("ipnetmas k0="+ipnetmaska rr[0]+"ipnetmask1="+ ipnetmaskarr[1]);
//alert("ippppp= "+ip+" nm="+nm);//In internet explorer this line is executed sometime
var networkarr=new Array(4)//not ok
//alert("ip= "+ip+" nm="+nm); //This alert is not working always
iparr=ipnetmask arr[0].split(".");//from this nothing is happening
//alert("iparr="+ iparr);
nmarr=ipnetmask arr[1].split(".");
for(i=0;i<iparr .length;i++)
{
networkarr[i]=iparr[i]&nmarr[i];
}
networkid=netwo rkarr.join(".")
ipnmaddr=networ kid+'/'+ipnetmaskarr[1]
//document.getEle mentById('ipadd ress').value=ip nmaddr;
document.addfor m.ipaddress.val ue=ipnmaddr;
if(firstvalue== ipnmaddr)
{
opener.document .viewform.useri d.value=documen t.addform.useri d.value;
opener.document .viewform.ipadd ress.value =document.addfo rm.ipaddress.va lue
opener.document .viewform.mode. value = "<%=FWBMModes.A DD%>";
opener.document .viewform.submi t();
self.close();
}
else
{
// The networkid is displayed dynamically
document.fgColo r="red"
var tbl = document.getEle mentById('tblgu i');
var lastRow = tbl.rows.length ;
if (lastRow >= 1)
{
tbl.deleteRow(l astRow - 1);
var row = tbl.insertRow(l astRow-1);
text = document.create TextNode("The IP address("+first value+") is changed to networkid");
row.appendChild (text)
document.addfor m.ignore.disabl ed=false;
flag=false;
return false;
}
else
{
var row = tbl.insertRow(l astRow);
text = document.create TextNode("The IP address("+first value+") is changed to networkid");
row.appendChild (text)
document.addfor m.ignore.disabl ed=false;
flag=false;
return false;
}
}
}
}
else
{
alert("Enter a valid NetMask before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
else
{
alert("Enter a valid IP Address before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
}[/CODE]
i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in mozilla perfectly but not in IE.
To check where is the fault i have written so many alert() but sometimes these are working.
Please someone read my code and tell me why its not working.
i am also sending you the function validateIPandNe tMask()
my alert statement is commented so that one can understand my code
[CODE=javascript]var enteredip;
function validateIPandNe tMask()
{
enteredip=docum ent.addform.ipa ddress.value
firstvalue=docu ment.addform.ip address.value;
//alert("fstvalue ="+firstvalu e)
ipnetmaskarr=fi rstvalue.split( "/");
ip=ipnetmaskarr[0];
nm=ipnetmaskarr[1];
//alert("ipnetmas k0="+ipnetmaska rr[0]+"ipnetmask1="+ ipnetmaskarr[1]);
if(ipnetmaskarr[1]==null)
{
if(validateIPAd dress(ipnetmask arr[0]))
{
if(isBrowserIE( ))
{
window.returnva lue=addform.use rid.value+'/'+addform.ipadd ress.value;
}
else
{
opener.document .viewform.useri d.value=documen t.addform.useri d.value;
opener.document .viewform.ipadd ress.value = firstvalue;
opener.document .viewform.mode. value = "<%=FWBMModes.A DD%>";
opener.document .viewform.submi t();
}
self.close();
}
else
{
alert("Enter a valid IP Address before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
else
{
//alert("ip= "+ip+" nm="+nm);
if(validateIPAd dress(ipnetmask arr[0]))
{
if(validateIPNe tmask(ipnetmask arr[1]))
{
if(isBrowserIE( ))
{
window.returnva lue=addform.use rid.value+'/'+addform.ipadd ress.value;
}
else
{
//alert("ipnetmas k0="+ipnetmaska rr[0]+"ipnetmask1="+ ipnetmaskarr[1]);
//alert("ippppp= "+ip+" nm="+nm);//In internet explorer this line is executed sometime
var networkarr=new Array(4)//not ok
//alert("ip= "+ip+" nm="+nm); //This alert is not working always
iparr=ipnetmask arr[0].split(".");//from this nothing is happening
//alert("iparr="+ iparr);
nmarr=ipnetmask arr[1].split(".");
for(i=0;i<iparr .length;i++)
{
networkarr[i]=iparr[i]&nmarr[i];
}
networkid=netwo rkarr.join(".")
ipnmaddr=networ kid+'/'+ipnetmaskarr[1]
//document.getEle mentById('ipadd ress').value=ip nmaddr;
document.addfor m.ipaddress.val ue=ipnmaddr;
if(firstvalue== ipnmaddr)
{
opener.document .viewform.useri d.value=documen t.addform.useri d.value;
opener.document .viewform.ipadd ress.value =document.addfo rm.ipaddress.va lue
opener.document .viewform.mode. value = "<%=FWBMModes.A DD%>";
opener.document .viewform.submi t();
self.close();
}
else
{
// The networkid is displayed dynamically
document.fgColo r="red"
var tbl = document.getEle mentById('tblgu i');
var lastRow = tbl.rows.length ;
if (lastRow >= 1)
{
tbl.deleteRow(l astRow - 1);
var row = tbl.insertRow(l astRow-1);
text = document.create TextNode("The IP address("+first value+") is changed to networkid");
row.appendChild (text)
document.addfor m.ignore.disabl ed=false;
flag=false;
return false;
}
else
{
var row = tbl.insertRow(l astRow);
text = document.create TextNode("The IP address("+first value+") is changed to networkid");
row.appendChild (text)
document.addfor m.ignore.disabl ed=false;
flag=false;
return false;
}
}
}
}
else
{
alert("Enter a valid NetMask before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
else
{
alert("Enter a valid IP Address before proceeding");
addform.ipaddre ss.focus();
return false;
}
}
}[/CODE]
Comment