• Home
  • Q&A
  • SCRIPT438: Object doesn't support property or method IE
 
29
0
0

SCRIPT438: Object doesn't support property or method IE

vikiforviaStackOverflow
December 20, 2012
0 score
2 answers

I have an option in my application where users can deactivate their profiles. Only admin can activate them again.

I have a class ActivateProfile with two methods userExist(userName)-that checks if user with that userName exists and his/her profile is deactivated and activateAccountByUser(userName) that activate the profile of the user again.

I call javascript function on click event on input type button

function activateProf() {

    var userName=document.getElementById("userName").value;

    if(userName=="")
    {
        alert("Полето е задолжително");
    }
    else
    {
        alert(userName+"1");


        ActivateProfile.userExist(userName,{callback:function(exist)
            {

                if(userName){


                    ActivateProfile.activateAccountByUser(userName);
                    alert("User is activated");
                }


                else {
                    alert("User does not exist");
                }




            }


        });
    }
}

This code works fine on chrome, mozilla but on Internet Explorer I got this error

SCRIPT438: Object doesn't support property or method userExist

Here is the code for Activate profile class

 public void activateAccountByUser(String userName) {

    try {
        Connection c = DBComm.getInstance().getConnection();
        Statement s = c.createStatement();
        ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");

        if (set.next()) {
            Statement st = c.createStatement();
            st.executeUpdate("update accounts set isauthorized='1' where userName='" + userName                    + "' and isauthorized='2'");
        }
        s.close();
        c.close();
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
    }
}


public boolean userExist(String userName) throws SQLException {
    //true exist
    //false does not exist
    boolean existEmbg = false;

    try {
        Connection c = DBComm.getInstance().getConnection();
        Statement s = c.createStatement();
        ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");

        if (set.next()) {
            existEmbg = true;
        } else {
            existEmbg = false;
        }
        s.close();
        c.close();
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
    }

    return existEmbg;
}

Could someone help me?

Answers

5 score

After some days searching the Internet I found that these error usually occurs when some html element id has the same id as some variable in the javascript function. After changing the name of one of them my code was working fine

answered December 22, 2012
2 score

I have added var for all the variables in the corrosponding javascript. That solved the problem in IE.

Previous Code

billableStatus = 1 ;
var classStr = $(this).attr("id").split("_");  
date = currentWeekDates[classStr[2]]; // Required    

activityNameId = "initialRows_" + classStr[1] + "_projectActivityName";
activityId = $("#"+activityNameId).val();        

var projectNameId = "initialRows_" + classStr[1] + "_projectName" ;
projectName = $("#"+projectNameId).val();        

var timeshitEntryId = "initialRows_"+classStr[1]+"_"+classStr[2];     
timeshitEntry = $("#"+timeshitEntryId).val();   

New Code

var billableStatus = 1 ;
var classStr = $(this).attr("id").split("_");  
var date = currentWeekDates[classStr[2]]; // Required    

var activityNameId = "initialRows_" + classStr[1] + "_projectActivityName";
var activityId = $("#"+activityNameId).val();        

var projectNameId = "initialRows_" + classStr[1] + "_projectName" ;
var projectName = $("#"+projectNameId).val();        

var timeshitEntryId = "initialRows_"+classStr[1]+"_"+classStr[2];     
var timeshitEntry = $("#"+timeshitEntryId).val();   
answered March 04, 2013
Discussion

-