PHP hierarchical array – Parents and childs

The suggestion by @deceze worked. However the input array needs to change a litte, like this… $rows = array( array( ‘id’ => 33, ‘parent_id’ => 0, ), array( ‘id’ => 34, ‘parent_id’ => 0, ), array( ‘id’ => 27, ‘parent_id’ => 33, ), array( ‘id’ => 17, ‘parent_id’ => 27, ), ); From https://stackoverflow.com/a/8587437/476: function … Read more

JavaScript DOM: Find Element Index In Container

You could make usage of Array.prototype.indexOf. For that, we need to somewhat “cast” the HTMLNodeCollection into a true Array. For instance: var nodes = Array.prototype.slice.call( document.getElementById(‘list’).children ); Then we could just call: nodes.indexOf( liNodeReference ); Example: var nodes = Array.prototype.slice.call( document.getElementById(‘list’).children ), liRef = document.getElementsByClassName(‘match’)[0]; console.log( nodes.indexOf( liRef ) ); <ul id=”list”> <li>foo</li> <li class=”match”>bar</li> … Read more

Style element based on selected

Impossible? Hold my beer. Make the select element aware of the current option. CSS can handle the rest. For this, all we need is a value assignment in the onchange event. With a little more effort you can also initialize the <select> tag by its original value; not included below but it’s super easy, just … Read more

How to pass data from 2nd activity to 1st activity when pressed back? – android

Start Activity2 with startActivityForResult and use setResult method for sending data back from Activity2 to Activity1. In Activity1 you will need to override onActivityResult for updating TextView with EditText data from Activity2. For example: In Activity1, start Activity2 as: Intent i = new Intent(this, Activity2.class); startActivityForResult(i, 1); In Activity2, use setResult for sending data back: … Read more