< Back to Code Samples
function go() {
    var text = document.getElementById('txtTestImage');
    var size = document.getElementById('selSize');
    var ds = document.getElementById('selDropShadow');
    var color = document.getElementById('txtColor');
    var img = document.getElementById('testImage');
    
    img.src = '';
    var temp;    
    
    if (color.value.substr(0,1) == "#") { 
        color.value = color.value.substr(1,6);
    }
    if (color.value.length == 3) {
        temp = '';
        for (i = 0; i < 3; i++) {
            temp += color.value.substr(i,1) + color.value.substr(i,1);
        }
        color.value = temp;
    }
    else if (color.value.length < 6) { 
        temp = color.value;
        for (i = 0; i < (6 - color.value.length); i++) {
            temp += color.value.substr((color.value.length % i),1);
        }
        color.value = temp;
    }
    else if (color.value.length > 6 || !color.value.match(/[A-Fa-f0-9]{6,}/)) { color.value = "000000"; }
    
    img.src = "/etsy/php/getText.php?text=" + text.value + "&size=" + size.options[size.selectedIndex].value + "&drop=" + ds.options[ds.selectedIndex].value + "&color=" + color.value + "&nocache=true";
}