4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 JSP in Javascript
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Infoheights
Junior WebHelper
Junior WebHelper


Joined: 19 Jan 2005
Posts: 1

PostPosted: Wed Jan 19, 2005 5:45 am (12 years, 9 months ago) Reply with QuoteBack to Top

<%@ page import="java.util.*" %>
<HEAD>
<SCRIPT language="JavaScript">
<!--

function startclock()
{
alert('in start clock');

var newTime = jspcode();
alert(newTime);
document.clockform.clockspot.value=newTime;

self.setTimeout('startclock()',1000);

}
<%!


int i;
%>

function jspcode()
{
alert('in jsp code');
<%
i = i+1;

%>

var jsTime = '<%= i %>';
alert(jsTime);
return jsTime;

}

//-->
</SCRIPT>
</HEAD>

<BODY>

<FORM name="clockform">
Current Time: <INPUT TYPE="text" name="clockspot" size="40">
</FORM>
<SCRIPT language="JavaScript">
<!--
startclock();
//-->
</SCRIPT>

</BODY>



This code is expected to increment the counter i every second. For some reason it maintains the value of 1 always. If I remove the setTimeout call and just keep refreshing the page it increments the value properly. Please help!!
OfflineView User's ProfileFind all posts by InfoheightsSend Personal MessageSend email
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.044852 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme