The resulting dynamic form (HTML + JavaScript)

zhaozj2021-02-16  107

Write what you have gone, you can use the web editing tool, you can use the web editing tool to first, and then specify a behavior of the template line program to generate editable according to the content of the template line. The form. At present, it is a bit problem with the support of the radical button (because the dynamic form is implemented by the array, there is a problem with the radio button group.) I have a problem with what is good. The following is the code of FlexGrid.js:

/ ** * Function Description: Editable Table Form FlexGrid * Properties: * Tableobj - Table Object (Reading) * ObjName - Table Object Name (read-only) * BackgroundColor - Unchecked Background Color ( Can be written) * Color - the foreground color (writable) of the content line is not selected (the foreground color of the control cannot be changed during unchecked (because the control is read-only attribute in the case of the selected line, the color is disabled )) * SELECTEDBACKGROUNDCOLOR - Select the background color of the content line (writable) * SelectedColor - Select the foreground color of the content line (written) * RowContentModule - Template Row Object (read-only) * Rowcount - Total Big number ( Not included in the head) * Colcount - Total number of columns (content ranks) * CellsModule - Tmmodeline cell content collection (HTML code form, CellsModule [column index (0 start)] - Returns the template content of the column) (read only) * StarTrowIndex - row index started by the content line (based on the entire table object (including header)) (read-only) * SELECTEDROWID - currently selected row index (based on The entire table object (including the header), indicates that there is no routine when -1) (read-only) *: * addNewRow () - Add new line * getValue (ObjName, RowIndex) - Return to the object value (ObjName object Name, RowIndex row index (does not include the header, starting from 0) * setValue (ObjName, RowIndex, Values) - Set the object value (ObjName object name, RowIndex row index (not including the header, starting from 0), VALUES Value) * SELECTEDROW (NewSelectedRowID) - Selected Row (NewSelectedRowID) * getobjType (OBJ) - Return to the type code of the form object (OBJ form object) * Deleterow () - Delete * selected lines of: Sundy_QSW * unit: www.topit.com.cn * date: 2004/05/13 * / / ** * function: editable form class constructor * input parameters: tblobj-- table object (

Object) * RowContentModule - Template Row Object (< Tr> Object) * This line is a dynamic table, which is used to construct other content lines, and the line does not exist (deleted) * current version only support text box, password box, multi-line Text box, radio list box, check button form object (tired) * For radio buttons, only support group group, do not support packets * ObjName - Table object name (character type,

Table name of the object) * Returns: editable form objects like FlexGrid * Author: Sundy_QSW * Unit: www.topit.com.cn * Date: 2004/05/13 * / function FlexGrid (tblobj, RowContentModule, objname) {this .tableobj = tblobj; this.objname = objname; this.backgroundColor = "# FFFFFF" this.color = "# ff0000"; this.selectedbackgroundColor = "# 63BADA" this.selectedColor = "# 0000ff"; this.RowContentModule = RowContentModule ; this.rowcount = 0; this.colcount = RowContentModule.cells.length; this.cellsmodule = new Array (this.colcount); this.startrowindex = RowContentModule.rowIndex; for (i = 0; i

/ ** * Function Description: Get the value of the object in the specified row * Enter parameters: objName - Object Name * RowIndex - row index (does not include the header, starting from 0) * Return value: Specify the value of the object in the line, when invalid return null * author: Sundy_QSW * unit: www.topit.com.cn * date: 2004/05/13 * / function tbl_getvalue (objname, rowindex) {var obj = eval ( "document.all." objname) ; If (obj == null) {return null;} if (rowindex> = this.rowcount) {return null;} if (this.rowcount == 0) {Return null;} if (this.rowcount! = 1) {OBJ = Obj [RowIndex];} var Ret = null; switch (obj.type) {copy 'button': ret = obj.value; break; case 'checkbox': Ret = obj.status; break; casser ': Return; case' file ': RET = 0; Break; Case' Image ': Ret = 0; Break; Case' Password ': Ret = Obj.Value; Break; Case' Submit ': RET = Obj.Value; Break; Case 'Reset': Ret = Obj.Value; Break; Case 'Text': Ret = Obj.Value; Break; Case 'SELECT-MULTIPLE': RET = NULL; BREAK; CASE 'SELECT -one ': Ret = Obj.Options [obj.selectedIndIndex] .Value; break; case' textarea ': Ret = Obj.Value; Break; Case' Hidden ': Ret = Obj.Value; Break DEFAULT: RET = NULL;}

Return Ret;}

/ ** * Function Description: Set the value of the object in the specified row * Enter parameters: objName - Object Name * RowIndex - row index (not including the header, starting from 0) * Vaules - value * Return Value: Success return true, otherwise returns false * OF: Sundy_QSW * unit: www.topit.com.cn * date: 2004/05/13 * / function tbl_setvalue (objname, rowindex, vaules) {var obj = eval ( "document.all." ObjName); if (obj == null) {return null;} if (rowindex> = this.rowcount) {Return False;} if (this.rowcount == 0) {Return False;} if (this.rowcount! = 1) {OBJ = Obj [RowIndex];} Switch (obj.type) {case 'button': return false; break; case 'checkbox': alert (values); obj.checked = values; return true; Case 'Radio': Return False; Break; Case 'File': Return False; Break; Case 'Image': Return False; Break; Case 'Password': Obj.Value = VALUES; RETURN TRUE; BREAK; CASE 'SUBMIT' : Returnaf false; Break; Case 'Reset': Return False; Break; Case 'Text': Obj.Value = VALUES; RETURUE; Break; Case 'Select-Multiple': Return False; Break; Case 'Select-One' : For (var i = 0; i

/ * ** Description: Returns the type of form object * Input parameters: obj-- form object * Return Value: returns the object support corresponding object code, the object does not support return -1 * OF: Sundy_QSW * Unit: WWW .topit.com.cn * Date: 2004/05/13 * / Function TBL_GETOBJTYPE (OBJ) {if (Obj.Type == 'Button') {RETURN 0;} IF (Obj.Type == 'Checkbox') { Return 1;}}} {return 2;} if (obj.type == 'image') {return -1;} if (obj.type == 'password') {Return 4;} if (obj.type == 'submit') {return 5;} if (obj.type == 'reset') {return 6;} if (obj.type == 'text') {RETURN 7; } If (obj.type == 'select-multiple') {return 8;} if (obj.type == 'select-one') {return 9;} if (obj.type == 'textarea') {Return 10;} if (obj.type == 'hidden') {return -1;} return -1;}

/ ** * Function Description: Select line * Enter parameters: newselectedrowid - The row index to select (including the header) (optional, default through the row index * return value: no * author : Sundy_qsw * Unit: www.topit.com.cn * Date: 2004/05/13 * / Function TBL_SELECTEDROW (NewSelectedRowID) {var awayvent = false; // What is the way to call, FALSE is a function call, True is called; if (newselectedrowid == null) {var obj = event.srcelement; while (obj! = null && obj.tagname! = 'tr') {Obj = obj.parentelement;} if (Obj! = null) {newselectedrowid = obj.rowIndex;} else {return;} fromevent = true;} if (newselectedrowid <0 || newselectedrowid == null) {return;} if (this.selectedrowid == newselectedrowid && fromevent) {return;} var cell; var content; if (! this.selectedrowid = - 1) {this.tableobj.rows [this.selectedrowid] .style.backgroundColor = this.backgroundColor; this.tableobj.rows [this.selectedrowid] .style.color = this. Color; for (var i = 0; i

this.tableobj.Rows [newselectedrowid] .cells [i]; content = cell.children [0]; for (var j = 0; j

Test page SAMPLE.htm

Dynamic Form Sample </ Title> <! - Reference Dynamic Table Library -> <script language = "javascript" src = "flexgrid.js"> </ script></p> <p><script language = "javascript"> var grd; // Defines dynamic table object function addNewRow () // Add new row {GRD.AddNewRow ();} Function getValue () // Get the contents of the specified cell {RowId = Document .all.sindex.value; objName = document.all.objnames.value; Alert (Grd.getValue (ObjName, RowID));} Function SetValue () // Setting the contents of the specified cell {RowID = Document.all.Sindex .value; objName = document.all.objnames.value; value; = document.all.newvalues.value; grd.setValue (ObjName, RowID, VALUES);} Function DELROW () // Delete Specified line {// alert (' DEL '); GRD.DELETEROW ();} </ script> </ hEAD></p> <p><body onload = "GRD = new flexgrid (Document.all.tsttbl, Document.all.RowModul, 'GRD'); // Instant Dynamic Table Object"></p> <p><Table Border = "1" ID = "TSTTBL"> <! - Dynamic Table Object -> <Tr> <TD COLSPAN = "7"> Form Object </ TD> </ TR> <TR> <TD> Text </ TD> <TD> TextArea </ TD> <TD> Radio </ TD> <TD> CheckBox </ TD> <TD> Password </ TD> <TD> Select </ TD> <TD> Hidden < / TD> </ tr> <TD> <TD> A1 <TD> <TD> A2 <TD> <TD> A3 </ TD> <TD> A4 </ TD> <TD> A5 </ TD> <TD> A6 </ TD> <TD> A7 </ TD> </ TD> <trid = "RowModul"> <! - Metal Object -> <TD> <input name = "a1" value = Text> </ td> <td> <textarea name = "a2"> textarea </ textarea> </ td> <td> <input type = "radio" name = "a3" value = 1> </ td > <TD> <input type = "checkbox" name = "a4"> </ td> <td> <input type = "password" name = "a5" value = "password"> </ td> <td> < Select name = "a6"> <option value = "1"> value is 1 </ option> <option value = "2"> value 2 </ option> <option value = "3"> value is 3 </ Option> <option value = "4"> value is 4 </ option> <option value = "5"> value 5 </ option> </ select> </ td> <td> <input type = "hidden" Name = "a7" value = "hidden"> </ td> </ tr> <tr> <td> 1 </ td> <td> 2 </ td> <td> 3 </ td> <td> 4 </ TD> <TD> 5 </ TD> <TD> 6 </ TD> <TD> 7 </ TD> </ TR> </ Table></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-11006.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="11006" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.035</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'bC_2B7Y2wd3Ru0aySqm_2Ff1FHLcoaT_2FgpI7c_2BSNjaF_2FSGyiTjmLpMaq1u7TZbMODd9Q2ZFx1NnuCJfDQ6SOHM9hzw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>