Javascript: find the id and show in the title of the element

2012-05-13 von Mario

This script shows the ID, if you move your mouse over the item.

 

function findIDandSetToTitle(obj) {

    //loop over all nodes of the obj
    for (i=0; i<obj.childNodes.length; i++) {

        if (obj.childNodes[i].tagName == "INPUT" && 
(obj.childNodes[i].type == "text" || obj.childNodes[i].type == "checkbox" 
|| obj.childNodes[i].type == "radio") ||
            obj.childNodes[i].tagName == "SELECT" ||
            obj.childNodes[i].tagName == "TEXTAREA" ||
            obj.childNodes[i].tagName == "A"
            )
        {
            obj.childNodes[i].title = "ID:" + obj.childNodes[i].id;
        }  

    }
}

 

Live Demo: Click
Download Demo: Example_find_ids.zip

Kategorie: IT Schlagwörter: , , , ,

jQuery: find parent form and make all textfields inside the form editable

2012-03-03 von Mario

This little jQuery script shows a solution for my next challenge.
It should be found, the parent form when the “bearbeiten” button was pressed.
After that, all the fields inside the form must be editable.

 

Live Demo: Click
Download Demo: Demo_001.zip

$(document).ready(function () {
   $("input:text").attr('disabled', 'disabled');
});

$('input:button[name="bearbeiten"]').click(function() {
   setEditable(this);
});

function setEditable(_this) {

   $(_this).closest("form").find("input:text").each(function(index, elem ) {
      $(elem).removeAttr('disabled');
   });
}

thanks goes to: A.K. ;)

Kategorie: IT Schlagwörter: , , , , , ,