Entry
How can I create an 'UNDO' last entry button for a text field?
Jun 16th, 2005 19:37
Syaefulloh Dj, Guest,
There are 2 possibilities :
1. If your text field is the only one element form.
<form name='frm'>
<input type='text' value='my first value'>
<input type='button' value='reset' onClick='javascript:this.form.reset
();'>
</form>
2. If you have many text field and only one text field is affected by
the button, you should do some tricks.
<html>
<head>
<script language="javascript">
var myTextValue = '';
function reset_text_value(){
document.frm.foo.value = myTextValue;
}
function save_text_value(){
myTextValue = document.frm.foo.value;
}
</script>
</head>
<body onload="javascript:save_text_value()">
<form name="frm">
<input type="text" name="foo" value="my text value">
<input type="button" value="reset" onclick="javascript:reset_text_value
()">
</form>
</body>
</html>
Hope these help!