473,395 Members | 1,496 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.

Function written in javascript is not working in internet explorer

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 validateIPandNetMask()
my alert statement is commented so that one can understand my code
Expand|Select|Wrap|Line Numbers
  1. var enteredip;
  2.     function validateIPandNetMask()
  3.     {
  4.  
  5.        enteredip=document.addform.ipaddress.value
  6.        firstvalue=document.addform.ipaddress.value;
  7.        //alert("fstvalue="+firstvalue)
  8.        ipnetmaskarr=firstvalue.split("/");
  9.        ip=ipnetmaskarr[0];
  10.        nm=ipnetmaskarr[1];
  11.        //alert("ipnetmask0="+ipnetmaskarr[0]+"ipnetmask1="+ipnetmaskarr[1]);
  12.        if(ipnetmaskarr[1]==null)
  13.        {
  14.             if(validateIPAddress(ipnetmaskarr[0]))
  15.             {
  16.                if(isBrowserIE())
  17.                 {
  18.                     window.returnvalue=addform.userid.value+'/'+addform.ipaddress.value;
  19.                 }
  20.                 else
  21.                 {
  22.                     opener.document.viewform.userid.value=document.addform.userid.value;
  23.                     opener.document.viewform.ipaddress.value = firstvalue;
  24.                     opener.document.viewform.mode.value = "<%=FWBMModes.ADD%>";
  25.                     opener.document.viewform.submit();
  26.                 }
  27.                 self.close();
  28.             } 
  29.               else
  30.             {
  31.                 alert("Enter a valid IP Address before proceeding");
  32.                 addform.ipaddress.focus();
  33.                 return false;
  34.             }
  35.        }
  36.         else
  37.         {
  38.         //alert("ip= "+ip+" nm="+nm);
  39.             if(validateIPAddress(ipnetmaskarr[0]))
  40.             {
  41.                 if(validateIPNetmask(ipnetmaskarr[1]))
  42.                 {
  43.                     if(isBrowserIE())
  44.                     {
  45.                         window.returnvalue=addform.userid.value+'/'+addform.ipaddress.value;
  46.                     }
  47.                     else
  48.                     {
  49.  
  50.                      //alert("ipnetmask0="+ipnetmaskarr[0]+"ipnetmask1="+ipnetmaskarr[1]);
  51.                         //alert("ippppp= "+ip+" nm="+nm);//In internet explorer this line is executed sometime
  52.                            var networkarr=new Array(4)//not  ok
  53.                            //alert("ip= "+ip+" nm="+nm); //This alert is not working always
  54.                         iparr=ipnetmaskarr[0].split(".");//from this nothing is happening
  55.                         //alert("iparr="+iparr);
  56.                         nmarr=ipnetmaskarr[1].split(".");
  57.                         for(i=0;i<iparr.length;i++)
  58.                         {
  59.                             networkarr[i]=iparr[i]&nmarr[i];
  60.                         }
  61.                         networkid=networkarr.join(".")
  62.                         ipnmaddr=networkid+'/'+ipnetmaskarr[1] 
  63.                         //document.getElementById('ipaddress').value=ipnmaddr;
  64.                         document.addform.ipaddress.value=ipnmaddr;
  65.                         if(firstvalue==ipnmaddr)
  66.                         {
  67.                             opener.document.viewform.userid.value=document.addform.userid.value;
  68.                             opener.document.viewform.ipaddress.value =document.addform.ipaddress.value
  69.                             opener.document.viewform.mode.value = "<%=FWBMModes.ADD%>";
  70.                             opener.document.viewform.submit();
  71.                             self.close();
  72.                         }
  73.                         else
  74.                         {
  75.                             // The networkid is displayed dynamically
  76.                                 document.fgColor="red"
  77.                                 var tbl = document.getElementById('tblgui');
  78.                                 var lastRow = tbl.rows.length;
  79.                                 if (lastRow >= 1) 
  80.                                 {
  81.                                     tbl.deleteRow(lastRow - 1);
  82.                                     var row = tbl.insertRow(lastRow-1);
  83.                                     text = document.createTextNode("The IP address("+firstvalue+") is changed to networkid");
  84.                                     row.appendChild(text)
  85.                                     document.addform.ignore.disabled=false;
  86.                                     flag=false;
  87.                                     return false;
  88.                                 }
  89.                                 else
  90.                                 {
  91.                                     var row = tbl.insertRow(lastRow);
  92.                                     text = document.createTextNode("The IP address("+firstvalue+") is changed to networkid");
  93.                                     row.appendChild(text)
  94.                                     document.addform.ignore.disabled=false;
  95.                                     flag=false;
  96.                                     return false;
  97.                                 }        
  98.                         }
  99.                     }
  100.  
  101.                  }
  102.                 else
  103.                 {
  104.                 alert("Enter a valid NetMask before proceeding");
  105.                 addform.ipaddress.focus();
  106.                     return false;
  107.                 }
  108.         }
  109.         else
  110.         {
  111.             alert("Enter a valid IP Address before proceeding");
  112.             addform.ipaddress.focus();
  113.             return false;
  114.         }
  115.       }
  116.     }
Oct 5 '07 #1
3 2891
dmjpro
2,476 2GB
What do you mean by "sometimes these are working." ?

Kind regards,
Debasis Jana
Oct 5 '07 #2
acoder
16,027 Expert Mod 8TB
BibhuAshish, welcome to TSDN!

Please use code tags when posting code:

[CODE=javascript]
JavaScript code here...
[/code]
Oct 5 '07 #3
pbmods
5,821 Expert 4TB
Heya, Bibhu.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Oct 5 '07 #4

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

Similar topics

0
by: indie | last post by:
does anyone know how to make javascript for internet explorer in order that it can read the picture from my webcam or may be free code from website??. i'm using camserv to get streaming picture...
25
by: Jeff | last post by:
Use the MS Script Editor included free with MS Office 2002 and above, for debugging Internet Explorer (IE). This subject is of great interest to many JS developers, as there is no obvious, low...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
2
by: Water Cooler v2 | last post by:
How do you enable/disable JavaScript in Internet Explorer v6?
26
by: Prisoner at War | last post by:
Hi, All: I have a JavaScript search engine that always causes MSIE 7 to do a top-of-page security "warning" (that top-of-page-bar, and not an "alert" )...but other websites' JavaScripts do not...
1
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not...
1
by: miked13 | last post by:
I have 4 textfields labeled "qtyA","qtyB","qtyC" and "GrandTotal". I have my calculate() function run Onchange of any of the "qty" fields and it displays it in "GrandTotal". I am trying to get my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.