i want to display time using hidden variable in a page,but
when i click button that page that hidden variable loosing
its value.i m sending the code also.

<script type="text/javascript" language="javascript">
var tick=0;

window.onload = function() {
//debugger

if(document.getElementById("hdnTicker").value != "")

tick =
parseInt(document.getElementById("hdnTicker").value);
setInterval("Timer()",1000);


}

function Timer()
{
//debugger
document.getElementById("hdnTicker").value = tick++;
//alert(document.getElementById("hdnTicker").value);

document.getElementById("lblTimeSpent").innerHTML = "0." + tick;
if(tick == 30)
{
//message or redirect to result window
alert('time is out');
//clearTimeout();
}
} </script>


<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="lblTimeSpent" runat="server"
Visible="true" ForeColor="Blue" ></asp:Label>
</td>

<td>
<%-- <asp:textbox EnableViewState="true"
id="hdnTicker" runat="Server"
style="visibility:hidden"></asp:textbox>--%>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btn" runat="server"
Text="hi" OnClick="btn_Click" Height="30px" Width="60px" />
</td>
</tr>
</table>




<%--<asp:HiddenField ID="txt" runat="server"
Visible="true" />--%>

</div>
</form>
<input type="hidden" id="hdnTicker" name="hdnTicker"
enableviewstate="true" runat="server" />

Answer Posted / vishnu tiruttani

You can use <%=Request("hdnVariable")%> to use that in the
javascript. So when the value is posted to server it can be
accessed.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi i want validations for two drop down lists. when user enter to second list by skipping first list alert box should appear. drop down validation Please choose an item from the drop down menu:

Choose a username:
Choose a username:
please any body help me thanks

1911


What do you mean by enumeration?

705


How to use external JavaScript file?

786


How to add/remove properties to object dynamically in javascript?

725


What are the different functional component in javascript?

684


Expand BOM and explain it?

719


What are the scopes of a variable in javascript?

768


What is difference between array.splice() and array.slice() method in javascript?

730


hi iM rahul.my questions is my project is a web based & developed using java,jsp. when i record it using qtp what script i will get like either browser("jdfjkf").page("nkf").... or javawindow("f d ").javaedit("Dasf").... plz clarify my doubt asap and i also need some vbscipt of java coding?

1937


Are java and javascript same?

697


How to update a function in javascript?

843


How do I enable cookies and javascript?

685


How are object properties assigned?

704


Which built-in method reverses the order of the elements of an array?

749


What is the use of a boolean object in javascript?

705