find a variable array key

Using a regex:

foreach (array_keys($array) as $search) {
	if (preg_match('/^FILL_YOUR_STUFF_(\d+)_NUMBER$/', $search, $matches)) {
		print_r($matches);
	}
}

By michael schouman on July 27, 2012 | Code snippets

Alert the biggest z-index on a page

alert(findHighestZIndex(div));
/**
 * Finding the highest z-index element in a document
 * @param elem
 */
function findHighestZIndex(elem)
{
	var elems = document.getElementsByTagName(elem);
	var highest = 0;
	for (var i = 0; i < elems.length; i++)
	{
		var zindex=document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");
		if ((zindex > highest) && (zindex != 'auto'))
		{
			highest = zindex;
		}
	}
	return highest;
}

By michael schouman on July 18, 2012 | Code snippets

Replace upload field with a image

First of all, the html:

<input id="imagefile" type="file" style="display:none;" name="uploadedfile"/>
<a class="btn-img" href="#"><img alt="Browse" src="/public/images/add.gif"></a>

Second, the jquery:


<script type="text/javascript">
$(document).ready(function() {
    $("A.btn-img").click(function () {
        $("#imagefile").trigger('click');
    });
});
</script>
By michael schouman on March 22, 2012 | Code snippets

Submit form with java

You created a form, but your client doesnt want a ugly submit button but plain text. Now your enter (or break) key will not submit the form anymore… There is a fix for that :-)


<input name="password" type="password" onclick="if(this.value == '********') this.value = ''" onblur="if(this.value == '') this.value = '********'" value="********" onKeyPress="submitMe()" />

function submitMe() {
    if (window.event.keyCode == 13)
    {
        document.loginForm.submit();
    }
} 

By michael schouman on March 16, 2012 | Code snippets

Style your submit button the right way

<input id="submit" type="submit" value="Send" name="submit">
#submit {
    background: url("/images/login.gif") no-repeat scroll 0 0 #FFFFFF;
    border: medium none;
    font-size: 0;
    height: 35px;
    width: 75px;
}
By michael schouman on March 7, 2012 | Code snippets

Code snippets
Compter Nerd Alert
Dynamic Interfaces
Het studentenleven
Informatie Architectuur
Interactieve Text
Interaction Design
Old projects