Printable Form Inputs

In recent days I’ve been working on the ability to print forms. For the sake of KISS principle I used the same form, for printing, that was used for data entry. I figured that the CSS would handle the look and feel. And for security I would use jQuery to disable the fields. Everything worked great as long as you don’t use Microsoft Internet Explorer. It seems that CSS in IE will not allow you to style a disabled form element. Here is a simple fix using jQuery to handle this. You may modify as needed. Let me know what you think and post back new modifications.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
securePrintInput = function() {
 
	$(":input").each(function(){
		if ($(this).val() == "" || ($(this).context.type == "checkbox" && $(this).attr("checked") == false)) {
			$(this).attr("disabled","disabled");
		}
		else {
			if ($(this).context.type == "text") {
				$(this).keydown(function(){
					return false;
				});
			}
			else if ($(this).context.type == "checkbox") {
				$(this).click(function(){
					$(this).attr("checked","checked");
				})
			}
			else if ($(this).context.type == "select-one") {
				$(this).keydown(function(){
					return false;
				});
				$(this).find("option").each(function(){
					if ($(this).attr("selected") == false) $j(this).remove();
				});
 
			}
		}
	});
}

Tagged with:
 

PHP Classes

In the past, more like years ago, I created a few PHP classes for public use. If you would like to utilize them go ahead and check them out. Let me know what you think.

Tagged with:
 

Fix IE Select Width using jQuery

It seems like every time you need something to work IE (MS Internet Explorer) really messes things up. So, I thought I’d publish this workaround.

1
2
3
4
5
6
7
fixIESelectWidth = function(obj) {
	if (!isFireFox()) {
		var w = $(obj).width();
		w = w + 5;
		$(obj).width(w);
	}
}

Tagged with:
 

isFireFox using jQuery $.support method

In the previous post I was using jQuery’s $.browser method that has been depreciated. I went ahead and added a function to simulate FireFox detection.

1
2
3
4
5
6
7
8
9
isFireFox = function() {
    var count = 0;
 
    $.each($.support, function(key,value) {
    	if (value) count = count + 1;
    });
 
    return (count >= 11) ? true : false;
}

Tagged with:
 

IE select option disabled fix using jquery

I spent a good couple hours fighting with IE and finally found a solution to fix the disabled option issue. Hope it helps you out.

1
2
3
4
5
6
7
8
9
10
11
12
13
ieLessThan8OptionDisable = function() {
    if ($.browser.msie && parseFloat($.browser.version) < 8) {
        $("select").find("[disabled]").addClass("disabled").removeAttr("disabled");
        $("select").change(function(){
            var selected = $(this).val();
            var disabled = $(this).find("[value="+selected+"]").hasClass("disabled");
            if (disabled) {
                alert("This option is disabled.\nSelect will be set to the first option.");
                $(this).find("option:first").attr("selected","selected");
            }
        });
    }
}

Tagged with:
 

Hello world!

Welcome to my website. This is my first post. Nothing fancy just a start.