Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Hierarchical Query Start with connect by prior 階層式查詢用法 SELECT s.role_id, s.role_name, s.role_base_on, b.role_name role_base_on_name FROM m_usr_role s... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data....
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;
    }
}