This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                7年前关闭。
            
        

我正在尝试使用javascript和php构建自己的表单生成器,
我在获取整个表单时遇到问题,因为我想在另一页上显示相同的表单。
我想生成一个包含整个表单链接的字符串。单击该链接后,将生成相同的表格

javascript代码是

 $('document').ready(function(){
            var flag=0;
            $(".divname").draggable({
                helper : "clone"
            });

            $( ".drop_class" ).droppable({

                drop: function( event, ui ) {

                    switch(ui.helper.context.id){
                        case "heading_id":
                            $( this ).append( "<div class='default_css' id='header'>Write Heading Here<input id='head_id' name='hello' class='common' type='text'/></div>" );
                            break;
                        case "textbox_id":
                            $( this ).append( "<div class='default_css'>Write Text Here<input id='text_id' class='common'type='text'/></br></div>" );
                            break;
                        case "textarea_id":
                            $( this ).append( "<div class='default_css'>Enter Information<textarea id='tarea_id' class='common'rows=5 cols=70></textarea></div>" );
                            break;
                        case "radio_id":
                            $( this ).append( "<div class='default_css'>Gender</br><input type='radio' value='male' name='sex'>Male<br><input type='radio' value='female' name='sex'>Female" );
                            break;
                        case "fullname_id":
                            $( this ).append( "<div class='default_css'>First Name<input id='fname_id' class='common' type='text'/>Last Name<input type='text'id='lname_id'/></br></div>" );
                            break;
                        case "mobile_id":
                            $( this ).append( "<div class='default_css'>Enter Mobile Number<input id='mob_id' class='common' type='text'/></div>");
                            break;
                        }
                        if(flag==0){
                            $( this ).append("<div class='default_css'><input type='button' id='submit_button' style='position:absolute;right:330px;bottom:0;'value='submit'/></div><div id='generate_id'><input type='button' style='position:absolute;right:100px;bottom:0;' value='Generate URL'/>");
                        }
                        flag = 1;
                    }
                });


            });


我如何获得完整表格

最佳答案

考虑

$formHTML = $("#idOfForm").html();

关于javascript - 如何以字符串形式获取整个表格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14030635/

10-09 17:50