How to refresh a web page in html when the text box value change dynamically?
Asked
Active
Viewed 7,274 times
-1
-
you could get a better answer if you explain the purpose of this. – amosrivera Mar 14 '11 at 06:24
4 Answers
0
I think you want the onChange javascript event.
<SCRIPT TYPE="text/javascript">
<!--
function checkEmail(mytext)
{
if(mytext.length == 0)
{
alert("You didn't type anything!");
}
}
//-->
</SCRIPT>
<FORM>
<INPUT NAME="email" onChange="doStuff(this.value)">
</FORM>

Lynn Crumbling
- 12,985
- 8
- 57
- 95
-
No! if we give onChange means the text box value need to change manually but i need that refresh action when it changed dynamically with out typing or clicking manually – Prabakaran Mar 14 '11 at 06:51
-
So you're saying that if the textbox value gets set by -anything-, script or user, you want an event that will handle it? – Lynn Crumbling Mar 14 '11 at 14:15
0
set document location to current value, and it will refresh!
document.location=document.location

d-live
- 7,926
- 3
- 22
- 16
0
Changing the value
property of an input element will not trigger its onchange()
handler.
You can reload the page with window.location.reload()
.

alex
- 479,566
- 201
- 878
- 984
0
Per user's additional info in the comment, it sounds like -any- change needs an action.
This sounds very similar to this question: (whose title is misleading; no jquery is needed) How to detect a textbox's content has changed
It seems like the best way to do it is by using window.setInterval to poll the field, and if it changes from its original value, call window.location.reload(). 500ms for setInterval is probably plenty fast enough.
So:
<SCRIPT TYPE="text/javascript">
<!--
function doStuff()
{
var myElement = document.getElementById("stuff");
if(myElement.length > 0)
{
window.location.reload();
}
}
//-->
</SCRIPT>
<BODY onload="self.setInterval('doStuff()',500)">
<FORM>
<INPUT TYPE="text" ID="stuff" NAME="stuff">
</FORM>
</BODY>

Community
- 1
- 1

Lynn Crumbling
- 12,985
- 8
- 57
- 95
-
Note, that I'm not actually comparing against the original value; I'm comparing against an empty string. – Lynn Crumbling Mar 14 '11 at 14:51