jt537
asked on
recall last entry
I would like to only recall the last entry.
input text box that I wish to save/call the last entries
<form name="myform">
<input type="text" name="mytext"><br>
<a href="javascript:getSearch (document. myform.myt ext)">Go</ a><br>
<a href="javascript:addSearch (document. myform.myt ext.value) ">Previous </a>
</form>
<html>
<head><title>Untitled</tit le>
<SCRIPT LANGUAJE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0
function addSearch(theTerm) {
top.curTerm++;
top.searchTerms[top.curTer m] = theTerm;
if (top.curTerm >= top.maxTerms) top.curTerms = -1;
totalTerm++
if (totalTerm==maxTerms+1) totalTerm--
}
function getSearch(theField) {
if (totalTerm == 0) return true
theField.value = top.searchTerms[actualTerm ]
actualTerm++
if (actualTerm == totalTerm || actualTerm == maxTerms+1) actualTerm=0
theField.focus();
theField.select();
}
// -->
</SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<input type="button" value="recall" onclick="getSearch(documen t.myform.m ytext)"><b r>
<input type="button" value="save" onclick="addSearch(documen t.myform.m ytext.valu e)">
</form>
</body>
</html>
</html>
input text box that I wish to save/call the last entries
<form name="myform">
<input type="text" name="mytext"><br>
<a href="javascript:getSearch
<a href="javascript:addSearch
</form>
<html>
<head><title>Untitled</tit
<SCRIPT LANGUAJE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0
function addSearch(theTerm) {
top.curTerm++;
top.searchTerms[top.curTer
if (top.curTerm >= top.maxTerms) top.curTerms = -1;
totalTerm++
if (totalTerm==maxTerms+1) totalTerm--
}
function getSearch(theField) {
if (totalTerm == 0) return true
theField.value = top.searchTerms[actualTerm
actualTerm++
if (actualTerm == totalTerm || actualTerm == maxTerms+1) actualTerm=0
theField.focus();
theField.select();
}
// -->
</SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<input type="button" value="recall" onclick="getSearch(documen
<input type="button" value="save" onclick="addSearch(documen
</form>
</body>
</html>
</html>
jt537,
So u can do this to only recall the last entry :
Source code
========================== ========== ====
<html>
<head><title>Untitled</tit le>
<SCRIPT LANGUAGE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0
function addSearch(theTerm) {
top.curTerm++;
top.searchTerms[top.curTer m] = theTerm;
if (top.curTerm >= top.maxTerms) top.curTerms = -1;
totalTerm++
if (totalTerm==maxTerms+1) totalTerm--
}
function getSearch(theField) {
if (totalTerm == 0) alert("No entry recorded !")
else
{
actualTerm = top.searchTerms.length - 1;
theField.value = top.searchTerms[actualTerm ]
theField.focus();
theField.select();
}
}
// -->
</SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<a href="javascript:getSearch (document. myform.myt ext)">Reca ll entry</a><br>
<a href="javascript:addSearch (document. myform.myt ext.value) ">Save entry</a>
</form>
</body>
It will now recall the last item only
<<<<<<<<<<<<<<<<<<<<>>>>>> >>>>>>>>>> >>
So can i solve your problem ?
<<<<<<<<<<<<<<<<<<<<>>>>>> >>>>>>>>>> >>
-- Holy Spirit
So u can do this to only recall the last entry :
Source code
==========================
<html>
<head><title>Untitled</tit
<SCRIPT LANGUAGE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0
function addSearch(theTerm) {
top.curTerm++;
top.searchTerms[top.curTer
if (top.curTerm >= top.maxTerms) top.curTerms = -1;
totalTerm++
if (totalTerm==maxTerms+1) totalTerm--
}
function getSearch(theField) {
if (totalTerm == 0) alert("No entry recorded !")
else
{
actualTerm = top.searchTerms.length - 1;
theField.value = top.searchTerms[actualTerm
theField.focus();
theField.select();
}
}
// -->
</SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<a href="javascript:getSearch
<a href="javascript:addSearch
</form>
</body>
It will now recall the last item only
<<<<<<<<<<<<<<<<<<<<>>>>>>
So can i solve your problem ?
<<<<<<<<<<<<<<<<<<<<>>>>>>
-- Holy Spirit
jt537,
P.S. Although it have a better solution to this question, but i don't use it because it will rewrite most of the script that u have given me.
-- Holy Spirit
P.S. Although it have a better solution to this question, but i don't use it because it will rewrite most of the script that u have given me.
-- Holy Spirit
One entry is so simple:
<html>
<head><title>Untitled</tit le>
<SCRIPT LANGUAJE="javascript"><!-- //
searchTerms = "";
// --></SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<input type="button" value="recall" onclick="this.mytext = top.searchTerms"><br>
<input type="button" value="save"
onclick="top.searchTerms= this.myText.value">
</form>
</body>
</html>
Michel
<html>
<head><title>Untitled</tit
<SCRIPT LANGUAJE="javascript"><!--
searchTerms = "";
// --></SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mytext"><br>
<input type="button" value="recall" onclick="this.mytext = top.searchTerms"><br>
<input type="button" value="save"
onclick="top.searchTerms= this.myText.value">
</form>
</body>
</html>
Michel
Too simple! forgot a form and a value:
<input type="button" value="recall"
onclick="this.form.mytext. value = top.searchTerms"><br>
<input type="button" value="save"
onclick="top.searchTerms= this.form.myText.value">
And it is still
<SCRIPT LANGUAGE="javascript"><!-- //
;-)
<input type="button" value="recall"
onclick="this.form.mytext.
<input type="button" value="save"
onclick="top.searchTerms= this.form.myText.value">
And it is still
<SCRIPT LANGUAGE="javascript"><!--
;-)
jt537,
How about this script, it use a hidden field to store the value ^_^:
<form name = test>
<input name = textBox type = text>
<input name = recallStore type = hidden>
<input type = button onClick = "document.forms.test.recal lStore.val ue = document.forms.test.textBo x.value" value = Store>
<input type = button onClick = "document.forms.test.textB ox.value = document.forms.test.recall Store.valu e;document .forms.tes t.textBox. focus();do cument.for ms.test.te xtBox.sele ct()" value = Recall>
</form>
-- Holy Spirit
How about this script, it use a hidden field to store the value ^_^:
<form name = test>
<input name = textBox type = text>
<input name = recallStore type = hidden>
<input type = button onClick = "document.forms.test.recal
<input type = button onClick = "document.forms.test.textB
</form>
-- Holy Spirit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mplungjan's answer works best.
So, what would u like us to do for u.
-- Holy Spirit