Note that there are some explanatory texts on larger screens.

plurals
  1. POspit items into different arrays and retrieving it back
    primarykey
    data
    text
    <p>this related to my previous question asked and thanks to every one here who is helping me to learn coding :D</p> <p>i was previously working on an undo button which kind of works but not there yet :(</p> <p>here is what i have done <a href="http://hybridimaginations.com/lambada/test.html" rel="nofollow">click here</a>. But the problem is since it goes step by step backwards it has to wait till the item where the previous color was applied in the same part. Is there a way i can split something like this <a href="http://jsfiddle.net/LdV4s/" rel="nofollow">click here</a> will this idea work out?</p> <p>here is the test html code:</p> <pre><code> &lt;div id="colour"&gt; &lt;input type="submit" name="r1" id="r1" value="1" /&gt; &lt;input type="submit" name="r2" id="r2" value="2" /&gt; &lt;input type="submit" name="r3" id="r3" value="3" /&gt; &lt;input type="submit" name="r4" id="r4" value="4" /&gt; &lt;input type="submit" name="r5" id="r5" value="5" /&gt; &lt;input type="submit" name="r6" id="r6" value="6" /&gt; &lt;/div&gt; &lt;div id="map"&gt; &lt;input type="radio" name="radio" id="layer_a" value="a" /&gt; &lt;label for="layer"&gt;layer_a&lt;/label&gt; &lt;input type="radio" name="radio" id="layer_b" value="b" /&gt; &lt;label for="layer"&gt;layer_b&lt;/label&gt; &lt;input type="radio" name="radio" id="layer_c" value="c" /&gt; &lt;label for="layer"&gt;layer_c&lt;/label&gt; &lt;input type="radio" name="radio" id="layer_d" value="d" /&gt; &lt;label for="layer"&gt;layer_d&lt;/label&gt; &lt;/div&gt; &lt;input name="selected" id="selected" type="hidden" value="" /&gt; &lt;input type="submit" name="undo" id="undo" value="undo" /&gt; &lt;div id="result"&gt;&lt;/div&gt; </code></pre> <p>here is the test jQuery code:</p> <pre><code> $("#colour input").click(function() { $("input[name='selected']").val(this.id); }); var arraymap = []; var array_a = []; var array_b = []; var array_c = []; var array_d = []; $("#map input").click(function() { var mape = $(this).attr('id'); var ccurrent = $("input[name='selected']").val(); arraymap.push(mape); // trying to split it into diffrent arrays // if (mape == "layer_a") { array_a.push(ccurrent); var araycurrent = array_a; } else if (mape == "layer_b") { array_b.push(ccurrent); var araycurrent = array_b; } else if (mape == "layer_c") { array_c.push(ccurrent); var araycurrent = array_c; } else if (mape == "layer_d") { array_d.push(ccurrent); var araycurrent = array_d; }; var mapid = arraymap[arraymap.length - 1]; var colid = arraycurrent[arraycurrent.length - 1]; var loca = mapid + colid; $("#result").append(mapid); }); $("#undo").click(function() { arraymap.pop(); var remover_map = arraymap[arraymap.length - 1]; // trying get it back from split arrays // if (remover_map == "layer_a") { array_a.pop(); var remover_col = array_a[array_a.length - 1]; } else if (remover_map == "layer_b") { array_b.pop(); var remover_col = array_b[array_b.length - 1]; } else if (remover_map == "layer_c") { array_c.pop(); var remover_col = array_b[array_c.length - 1]; } else if (remover_map == "layer_d") { array_d.pop(); var remover_col = array_a[array_d.length - 1]; }; var remove = remover_map + remover_col; $("#result").append(remove); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload