This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes java script  error help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "java script  error help please" Watch "java script  error help please" New topic
Author

java script error help please

Makhana Jiggu
Greenhorn

Joined: Nov 09, 2005
Posts: 11
When I run the following jsp to automaticcally refresh every 10 seconds i'm geting javascript error that object is null on line document.refreshForm.submit(). can you please help on sloving the issue.
I double checked the stuts file and action and form path has been defined.

<%@ page import='java.util.*' %>

<%@ page import='presentation.action.RefreshTimer' %>

<%@page import='presentation.action.RefreshAction'%>

<%@page import='presentation.form.RefreshForm'%>

<script language="javascript" >

var temp = window.setInterval('submitPage()',10*1000);


function submitPage(){


alert("before count submit");

document.refreshForm.submit();

var xyz = <%=application.getAttribute("counter")%>

alert("New Request is " + xyz);

}

</script>




<html:form action="/refresh.do" method="post" onsubmit ="submitPage()">


</html:form>


Jiggu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Moved to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Where is refreshForm defined?
Makhana Jiggu
Greenhorn

Joined: Nov 09, 2005
Posts: 11
Bear,
RefreshForm is deifned in the struts file of the action path(refresh.do) and form bean
<form bean name ="refreshForm" path="presentation.form.RefreshForm">
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

That is not in your above example.
bujji makani
Greenhorn

Joined: Jan 10, 2006
Posts: 4
The form name is defined in sturts config file of that particluar action which is refresh.do

Even if i declare the form name as myform when i call the jsp page it gives me an error that document.myForm is not an object or is null. How can i resolve this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

In order for the reference document.refreshForm to resolve to an actual element, there has to be a form element with that name defined on the page. Until there is, you are going to continue to get the error.

What are you trying to accomplish by submitting a form that does not exist on the page?
bujji makani
Greenhorn

Joined: Jan 10, 2006
Posts: 4
Bear,

I defined on the form page as follows:
<html:form name ="refreshForm" action="/refresh.do" method="post" type ="presentation.form.RefreshForm">

This does not work so I created a hidden element but did not work either.
<input type="hidden" name="refreshForm" value="count" />

I want to submit the form to the server to get new values from database.
how can i submit this form from jsp page to the server without using submit buttons.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You already posted the code above to do it.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

This does not work


This is not useful information that will help diagnose the problem. How does it not work?


This does not work so I created a hidden element but did not work either.


Stabbing in the dark is rarely effective.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
document.refreshForm.submit();


<input type="hidden" name="refreshForm" value="count" />


As Bear pointed out, refreshForm needs to be a form, you can't define it as an input element.
[ January 30, 2006: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java script error help please
 
Similar Threads
javascript var
document.Form1 has no properties error
readyState=4 and Http 404 error in Ajax /Struts
JavaScript Validation in struts
html select onchange problem