Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Display Results for Push & Pop Values

    I have checked the forum and there are similar threads, but nothing that deals exactly with my issue.
    I have 2 Arrays and a variable. I need to push an item onto the variable, and then with a second click push it onto Array 1. Then with i click a second button, the item in the varible is push onto Array 2, and the item in Array 1 is Poped onto the Variable.

    Here is the code i have come up with, but i cannot pop the item from the Variable onto Array 2.

    Any ideas:

    <TITLE>Stacking up!</TITLE>

    // 'txtPop.value = popBackStack();showStack(theList);pushForStack(txtPop.value);

    // 'PushForStack(txtPop.value);txtPush.value"";txtPop.value = popBackStack();showStack(theList);showStack2(theList2);'

    var backStack = new Array();
    var forStack = new Array();
    var curUrl = document.getElementById("txtPop");

    function pushStack(newVal) {
    curUrl = newVal;

    function pushForStack(newVal) {
    CurUrl = newVal;

    function popBackStack() {
    var popVal = backStack.pop();
    if (popVal == undefined)
    return "Nothing left!";
    return popVal

    function popForStack() {
    var popVal = forStack.pop();
    if (popVal == undefined)
    return "Enter a new URL";
    return popVal;

    function showStack(theSelect){
    theSelect.options.length = 0;
    for (var i = 0; i < backStack.length; i++){
    var theOption = new Option(backStack[i]);
    theSelect.options[theSelect.options.length] = theOption;

    function showStack2(theSelect){
    theSelect.options.length = 0;
    for (var i = 0; i < forStack.length; i++){
    var theOption = new Option(forStack[i]);
    theSelect.options[theSelect.options.length] = theOption;

    <table width="104%" height="364" border="5" cellpadding="3" cellspacing="3">
    <th width="30%" height="78" scope="col"><p>
    <INPUT type=button value="Back" onClick='txtPop.value = popBackStack();showStack(theList);pushForStack(curUrl);
    <th width="46%" scope="col"><p>
    <INPUT type=text name=txtPush>
    <INPUT type=button value="Push" onClick='pushStack(txtPush.value);txtPush.value="";txtPop.value = curUrl; showStack(theList);'>
    <th width="24%" scope="col"><p><INPUT type=button value="Forward" onClick="txtPop.value = popBackStack();showStack2(theList2);"></p></th>
    <SELECT name="theList" size=12>
    <td><p><center><INPUT type=textki name=txtPop size=25></center></p></td>
    <SELECT name="theList2" size=12>

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Thanked 1,012 Times in 1,009 Posts
    To put your code into the code tags use the # icon not the #i icon.
    This should be in the javascript form not the dom and json form.
    You don't identify array 1 or array 2 so I have to guess, but I think your problem is this function:
    function pushForStack(newVal) {
    CurUrl = newVal;
    CurUrl = newVal; The capital makes this a different variable. Think it S/B curUrl = newVal;


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts