Popular Posts
jQuery : post/get using data() as param object <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html... android.intent.action.SCREEN_ON & android.intent.action.SCREEN_OFF First, I've tried create a receiver to receive screen on/off and register receiver on AndroidManifest.xml like below, but unfortunately ... runas RUNAS 使用方法: RUNAS [ [/noprofile | /profile] [/env] [/netonly] ] /user: program RUNAS [ [/noprofile | /profile] [/env] [/netonly] ...
Blog Archive
Stats
Html form operation
var JSUtil = {
    parseFormElement : function(form){
        var items = [];
        for(var i = 0; i < form.elements.length; i++){
            var element = form.elements[i];
            switch(element.tagName){
            case "INPUT":
                switch(element.type){
                    case "text":
                    case "hidden":
                    case "password":
                    case "submit":
                    case "radio":
                        items.push(this.createHiddenInput(element.name, element.value));
                        break;
                    case "checkbox":
                        if(element.checked) items.push(this.createHiddenInput(element.name, element.value));
                        break;
                    case "reset":
                        break;
                    case "image":
                        break;
                    case "file":
                        break;
                    case "button":
                        break;
                }
                break;
            case "SELECT":
                if(element.multiple){
                    for(var j = 0; j < element.options.length; j++){
                        var option = element.options[j];
                        if(option.selected) items.push(this.createHiddenInput(element.name, option.value));
                    }
                }else{
                    items.push(this.createHiddenInput(element.name, element.value));
                }
                break;
            case "TEXTAREA":
                items.push(this.createHiddenInput(element.name, element.value));
                break;
            }
        }
        return items;
    },
    createForm : function(elements){
        var f = document.createElement("form");
        this.setFormElement(f, elements);
        return f;
    },
    setFormElement : function(form, elements){
        var items = elements || [];
        for(var i in items){
            form.appendChild(this.createHiddenInput(items[i].name, items[i].value));
        }
    },
    createHiddenInput : function(name, value){
        var e = document.createElement("input");
        e.type = "hidden";
        e.name = name;
        e.value = value || "";
        return e;
    }
}