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" />



i want to display time using hidden variable in a page,but when i click button that page that hidde..

Answer / 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

More JavaScript Interview Questions

In javascript chained select menus are available.first select menu is worked and others are disabled.when we select any one option then the next select menu will worked having option releated to selcted in first select menu.How it possible? what is the coading of this programme?

1 Answers  


Which is better for or foreach in javascript?

0 Answers  


java pgme for class members hours:minutes:seconds then the constructor expects milliseconds as assignment and initialize data members the members function print hh:mm:ss 90,000 milliseconds passed in constructor then the output is 00:01:30

0 Answers  


Is javascript enabled on my computer?

0 Answers  


what is inheritence

6 Answers   Verifone, Wipro,






Does javascript support automatic type conversion, if yes give example.

0 Answers  


How to write html code dynamically using JavaScript?

0 Answers  


What is slug in javascript?

0 Answers  


How to test for bad numbers using javascript?

0 Answers  


What is the difference between undeclared & undefined?

0 Answers  


What does the attribute defer/async do when added to the script tag?

0 Answers  


Difference json arrary vs json object ?

0 Answers  


Categories