/*variable that stands to count how many times has the user clicked the element*/ var iterativeVariable = 0; /*variable to hold the height that the div #allFields will have*/ var iterativeVariable2 = 0; /*changes the div #allFields height*/ function allFieldsHeight(theHeight) { document.getElementById('allFields').style.height = theHeight + 'em'; } /*function that happens when user clicks a certain element*/ function showAllFields() { /*see how many times has the user clicked*/ if (iterativeVariable%2 == 0) { /*turn the arrow upside down*/ document.getElementById('insertCouncilsLegend').innerHTML = 'Adicionar Dados ' /*function that TRIES :( to change height from the div #allFields several times in a looped way using timeout*/ function growHeight() { allFieldsHeight(iterativeVariable2); iterativeVariable2++; if (iterativeVariable2 == 20) { clearTimeout(t); } t = setTimeout("growHeight()", 100); } /*add 1 to this variable to change the value that tells us how many times has the user clicked*/ iterativeVariable++; } else { /*turn the arrow upside down again*/ document.getElementById('insertCouncilsLegend').innerHTML = 'Adicionar Dados ' /*add 1 to this variable to change the value that tells us how many times has the user clicked*/ iterativeVariable++; } }