aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Famous Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Famous "Object  expected"error,Wishing Browser Independent" Watch "Famous "Object  expected"error,Wishing Browser Independent" New topic
Author

Famous "Object expected"error,Wishing Browser Independent

vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
Hi all Java gurus,
u all might have faced the famous javascript error ie"Object expected" and similarly might have faced browser dependency problem.I hope these problems would be sorted out soon so that we developers are relieved of the load of debugging javascript.
I request you all to please start a list mentioning the circumstances in which 'this' error occurs and the possible remedy over it.So that it will be useful to all developers.Do you all agree guys?Thanks and expecting a huge list.


VAIBHAV <BR>SCJP
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
There can be such a huge discrepencies between Netscape and IE's javascript calls, and even more when you go from 2.0 to 5.0 browsers. I think most of us see it as just a pain that we have to deal with because there is no way that it will ever be the same. So knowing the differences is the key. Or what I do is not memorize the differences, but now how to fix it when it comes up. Let me tell you, my debugging skills sure has improved.
Bill
vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
I m currently getting object expected error in the following code.Is it because I m using the the variables defined outside the javascript fn.
I m not able to fix it.Can anybody fix it please?Thanks.
-----------------------code----------------------------
out.println("<td><input type='button' value='Submit' onClick='return validation(req)'></td>"); //error here
out.println("<td><input type='reset' value='Cancel'></td>");
out.println(" </tr>");
out.println("</form>");
out.println("</table>");
out.println("</center>");
out.println("</div>");
out.println("</body>");
out.println("<script language='javascript'>");
out.println("<!--");
out.println(" function validation(HttpServletRequest req){ ");
out.println("if(document.myform.loginname.value.length==0)");
out.println("{alert('Please Enter Login Name.');");
out.println("return false;}");
out.println("if(document.myform.password.value.length==0)");
out.println("{alert('Please Enter Password.');");
out.println("return false;}");
/**********************JDBC CONNECTION************************/
try
{
i=1;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con =DriverManager.getConnection("jdbc dbc:vaibhav","vaibhav","vaibhav");

String query="SELECT * FROM Administrator WHERE login=? AND password=?";
pstmt = con.prepareStatement(query);
pstmt.setString(1,req.getParameter("loginname"));i++;
pstmt.setString(2,req.getParameter("password"));i++;
rst=pstmt.executeQuery();

//does not reach here---- while(rst.next())
{

{
//defined at class level loginnamearr[i-1]=rst.getString("login");
passwordarr[i-1]=rst.getString("password");
out.println(" if(document.myform.loginname.value!="+loginnamearr[i-1]+") ");
out.println(" { alert('Login Name Incorrect.'); return false;} ");
out.println(" if(document.myform.password.value!="+passwordarr[i-1]+") ");
out.println(" { alert('Password Incorrect.'); return false;} ");
out.println(" else{ document.myform.submit();} ");
out.println(" return true;}");
out.println("-->");
out.println("</script>");
 
 
subject: Famous "Object expected"error,Wishing Browser Independent