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.mytext)">Go</a><br>
<a href="javascript:addSearch(document.myform.mytext.value)">Previous</a>
</form>




<html>
<head><title>Untitled</title>
<SCRIPT LANGUAJE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0

function addSearch(theTerm) {
 top.curTerm++;
 top.searchTerms[top.curTerm] = 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(document.myform.mytext)"><br>
<input type="button" value="save" onclick="addSearch(document.myform.mytext.value)">
</form>
</body>
</html>
</html>
jt537Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HolySpiritCommented:
jt537,
So, what would u like us to do for u.
-- Holy Spirit
0
HolySpiritCommented:
jt537,
So u can do this to only recall the last entry :

Source code
========================================
<html>
<head><title>Untitled</title>
<SCRIPT LANGUAGE="javascript">
<!--
searchTerms = new Array();
maxTerms = 10;
curTerm = -1;
totalTerm = 0
actualTerm = 0

function addSearch(theTerm) {
 top.curTerm++;
 top.searchTerms[top.curTerm] = 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.mytext)">Recall entry</a><br>
<a href="javascript:addSearch(document.myform.mytext.value)">Save entry</a>
</form>
</body>

It will now recall the last item only

<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
So can i solve your problem ?
<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>

-- Holy Spirit
0
HolySpiritCommented:
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
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Michel PlungjanIT ExpertCommented:
One entry is so simple:

<html>
<head><title>Untitled</title>
<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
0
Michel PlungjanIT ExpertCommented:
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"><!-- //

;-)
0
HolySpiritCommented:
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.recallStore.value = document.forms.test.textBox.value" value = Store>
<input type = button onClick = "document.forms.test.textBox.value = document.forms.test.recallStore.value;document.forms.test.textBox.focus();document.forms.test.textBox.select()" value = Recall>
</form>
-- Holy Spirit
0
Michel PlungjanIT ExpertCommented:
HS: simpler to use
onClick="this.form.recallStore.value = this.form.textBox.value"
and

this.form.textBox.value = this.form.recallStore.value;
this.form.textBox.focus();this.form.textBox.select()

But anyway, the value disappears when another page is loaded so the top.searchTerms is needed to persist the term across pages.

Michel
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jt537Author Commented:
mplungjan's answer works best.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.