JSFiddle - React, Tailwind, and code Playground

by f3ry

HTML

<div id="example" onclick="create_form();">
       click me
</div>

CSS

#example{
    width: 100px;
    height:50px;
    background: blue;
}

.web_dialog_overlay
{
   position: fixed;
   top: 0;
   right: 0;
   bottom: 0;
   left: 0;
   height: 100%;
   width: 100%;
   margin: 0;
   padding: 0;
   background: #000000;
   opacity: .15;
   filter: alpha(opacity=15);
   -moz-opacity: .15;
   z-index: 101;
   /*display: none;*/
}
.web_dialog
{
   /*display: none;*/
   position: fixed;
   width: 380px;
   height: 200px;
   top: 50%;
   left: 50%;
   margin-left: -190px;
   margin-top: -100px;
   background-color: #ffffff;
   border: 2px solid #336699;
   padding: 0px;
   z-index: 102;
   font-family: Verdana;
   font-size: 10pt;
}
.web_dialog_title
{
   border-bottom: solid 2px #336699;
   background-color: #336699;
   padding: 4px;
   color: White;
   font-weight:bold;
}
.web_dialog_title a
{
   color: White;
   text-decoration: none;
}
.align_right
{
   text-align: right;
}

JavaScript

function get_form(r, c){
       var form = '<div id="dialog" class="web_dialog">'+
	'<form name="myForm">'+
	'<table style="width: 100%; border: 0px;" cellpadding="3" cellspacing="0">'+
      '<tr>'+
         '<td class="web_dialog_title">Example form</td>'+
         '<td class="web_dialog_title align_right">'+
            '<a href="#" id="btnClose" onclick="close_form();">Close</a>'+
         '</td>'+
     '</tr>'+
      '<tr>'+
         '<td>&nbsp;</td>'+
         '<td>&nbsp;</td>'+
      '</tr>';
   for (var i = 0; i < r; i++){
	   form += '<tr>';
	   for (var j = 0; j < c; j++){
		   form += '<td><input type="text" id="row-1-age" name="row-'+(i+j)+'" value="'+j+'"></td>';
	   }
	   form += '</tr>';
   }
   form += 	'</tr>'+
      '<tr>'+
         '<td colspan="2" style="text-align: center;">'+
            '<input id="nSubmit" type="button" value="Submit" onclick="close_form();"/>'+
         '</td>'+
      '</tr>'+
	 '</table>'+
   '</form>'+
   '</div>';
    return form;
}

function create_form(){
    $("body").append(get_form(3,3));
}

function close_form(){
	$('#dialog').remove();
}