Function written in javascript is not working in internet explorer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BibhuAshish
    New Member
    • Oct 2007
    • 34

    #1

    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 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]
    Last edited by acoder; Oct 5 '07, 07:09 AM. Reason: Added code tags
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    What do you mean by "sometimes these are working." ?

    Kind regards,
    Debasis Jana

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      BibhuAshish, welcome to TSDN!

      Please use code tags when posting code:

      &#91;CODE=javas cript]
      JavaScript code here...
      [/CODE]

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

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

        Comment

        Working...