JS control: intelligent input

xiaoxiao2021-03-06  14

/ * ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------- *

* Page initialization work: *

* JS_IO_SMARTINPUT_BUILDDIV (); // Building a layer when the [Display Layer page] is initialized *

* Document.onkeyDown = JS_IO_SMARTINPUT_RESPONSEUPDOWNENTERKEY; *

* // In the [Layer Embedded Page] Response "On, Determine" Event *

* ------------------------------------------------- ----------------------- * /

/ *** @Param OBJ: Cascum Into "Text Box Object" * @Param Urlname: Query page "SmartInput.jsp" relative to "page of this control" * @Param SmartInputsql: SQL statement * @Param BackcellsName: Returns the list of fields, requires: 1. The first is the "new" identification name (its value is 0: new, 1: Remove from the database) * Requires each field on the page requires unique, its order Companied with SQL) " ] Separate * @Param Viewcellsindex: The field you need to display in the "Query Field List" start from 0, each field is separated from [:].

* @Param isshowwidget [This value is obtained from > DEFAULT = 1]: The control is to be displayed, 0: Hide 1 and Other: Display * @Param isneWallow [This value is from Get, Default = 1]: Do you allow users to add parameter parameters, 0: Do not allow 1: Accessible If [0: Do not allow]: Use the [ESC] button, or [Tab] button, or click on the control. [X], the content input by the user to empty out * * / function js_io_smartInput_onfocus (obj, urlName, smartInputSQL, backCellsName, viewCellsName, viewCellsIndex) {var isShowWidget = obj.getAttribute ( "isShowWidget"); if (isShowWidget == null || isshowwidget == "" "{isshowwidget =" 1 ";} var isnewallow = obj.getattribute (" isnewallow "); if (isnewallow == null || isneWallow ==") {isneWallow = "1";} if (isShowWidget == "1") {// set parameters (into cookie) var smartInputName = obj.name; // contains smartInput control 'input with the name' js_io_smartInput_setParam (smartInputSQL, backCellsName, viewCellsName, viewCellsIndex, isNewAllow, isShowWidget , SmartInputName); JS_IO_SMARTINPUT_FILLFRAME ('SmartInputFrame', URLNAME); // Filled layer JS_IO _SmartInput_texttail (); // When the text box gets focus, the cursor is in the text last} else {js_io_smartinput_setcookie ("IssshowWidget", "0");}} / * @ Change Layer embedded page @Param Myframe: Frame name @Param URL: Page URL * / Function JS_IO_SMARTINPUT_FILLFRAME (MyFrame, URL) {var cal = url; // acquire the frame Cal.SRC = URL;}

// set the parameter (put cookie) function js_io_smartInput_setParam (smartInputSQL, backCellsName, viewCellsName, viewCellsIndex, isNewAllow, isShowWidget, smartInputName) {// clear the original value of Cookie / * js_io_smartInput_clearCookie ( "smartInputSQL"); js_io_smartInput_clearCookie ( "backCellsName"); js_io_smartInput_clearCookie ( "viewCellsName"); js_io_smartInput_clearCookie ( "viewCellsIndex"); js_io_smartInput_clearCookie ( "isNewAllow"); js_io_smartInput_clearCookie ( "smartInputName"); js_io_smartInput_clearCookie ( "isShowWidget"); * / // set the new Cookie js_io_smartInput_setCookie ( "smartInputSQL", smartInputSQL ); js_io_smartInput_setCookie ( "backCellsName", backCellsName); js_io_smartInput_setCookie ( "viewCellsName", viewCellsName); js_io_smartInput_setCookie ( "viewCellsIndex", viewCellsIndex); js_io_smartInput_setCookie ( "isNewAllow", isNewAllow); js_io_smartInput_setCookie ( "smartInputName", smartInputName); js_io_smartInput_setCookie ( " Isshowwidget ", ISSHOWIDGET);

/ ** * text box response user keyboard action * @Param Obj: text box object * @Param mycolor: highlight color * * / function js_io_smartinput_responseKey (Obj, mycolor) {var cal = document.getlementByid ("MartInputdiv") ; If (JS_IO_SMARTINPUT_GETCOOKIE ("IsshowWidget") == "1") {if (event.keycode == 27 || Event.keycode == 9) {// key [esc] [Tab] if (Cal.Style.Display ! = "none") {JS_IO_SMARTINPUT_CLOSEDIV ();}} else if (event.keycode == 40) {// Down arrow: Move the focus to SmartInput box // If the control is allowed, and the control is hidden, then it appear if (cal.style.display == "none") {js_io_smartInput_showDiv (obj); // display layer} else {js_io_smartInput_goDown ( 'smartInputBody', 'smartInputTable', myColor);}} else if (event.keyCode == 13 || Event.keycode == 20 || Event.keycode == 16 || Event.KeyCode == 17) {} else {if (JS_IO_SMARTINPUT_GETCOOKIE ("IsshowWidget") == "1" && ca.style. Display == "none") {js_io_smartinput_showdiv (obj); // Display Layer} JS_IO_SMARTINPUT_REF ( Obj); // Other keys: Execute SmartInput function}}} / * Clear input content * @ param backcellsname: Need to empty name string, each name is ":" Separate * / function js_io_smartInput_clearinput (CellsArray ) {For (var i = 1; i

/ * Click "Down Key", the function moves the focus to "layer", and highlights the first line of "Query Results" @Param SmartInputBody: Frame Inside the page Body ID such as: @Param SmartInputTable: Shows" Query Results "Table ID, such as:

@Param MyColor: Highlight color (must lowercase:, if # ff0000) * / function js_io_smartinput_godown (SmartInputBody, smartInputTable, myColor) {var objBody = document.smartInputFrame.document.getElementById (smartInputBody); // Object objBody.focus (); // get the focus let layer embedded page var smartInputTable = document.smartInputFrame.document.getElementById (SmartInputTable); //
Object var colcount = smartinputtable.rows.Length; // Table number IF (Colcount> 0) {var mycol = smartinputtable.rows (1); mycol.style.BackgroundColor = mycolor; }} / * @ keyUp response to each event, the contents of the input submitted to "layer" processing @param obj:! object generator of the event * / function js_io_smartInput_ref (obj) {if (document.smartInputFrame = null && document.smartInputFrame.smartInputResponseForm ! = null) {document.smartinputFrame.smartInputRespo Nseform.smartinputcode.value = obj.value; document.smartinputframe.smartInputResponseform.submit () return true;}}

/ ** is turned off by key [ESC] [Tab] closing the button [x] Turn the layer when the layer is turned off, * * * / function js_io_smartinput_closediv () {var cal = document.getlementByid ("MartInputdiv"); js_io_smartinput_hidediv (CAL); // restore "new identity" var backCellsName = js_io_smartInput_getCookie ( "backCellsName"); var cellsArray = backCellsName.split! ( ":"); // parse backCellsName if (cellsArray [0] = "NULL" && document.all (cellsArray [ 0])! = Null) {document.all (CellsArray [0]). Value = "0";} // If the parameter does not allow new, all the value is empty VAR isneWallow = JS_IO_SMARTINPUT_GETCOOKIE ("isnewallow"); if (isNewAllow == "0") {js_io_smartInput_clearInput (cellsArray);} // move the cursor in the input box var smartInputName = js_io_smartInput_getCookie ( "smartInputName"); document.all (smartInputName) .focus ();}

/ * @ DESC Response [Keyboard Up / Lower / Determined Key], highlight User Select Table Ring @Param Event (System Event) @Param SmartInputTable: You need to respond to table events "ID @Param HightlightColor: selected in the colors @param lowLightColor: color color @memo unselected row needs lowercase application example: document.onkeydown = js_io_smartInput_responseUpDownEnterKey; // page response "left, upper, lower, OK button" event * / function js_io_smartInput_responseUpDownEnterKey () {var smartInputTable = document .getElementByid ("smartinputtable"); // Table Object VARHTLIGHTCOLOR = '# ff0000'; // "Highlight" color var lowligthcolor = ''; // "Unchecked" Color var colcount = smartinputtable.rows .length; // Table number IF (Event.keycode == 38) {// Up key for (i = 1; i

if (i == (colCount - 1)) {smartInputTable.rows (1) .style.backgroundColor = hightLightColor;} else {smartInputTable.rows (i 1) .style.backgroundColor = hightLightColor;} break;}}} else IF (Event.KeyCode == 13) {// Determines the "Table of the table" in the user [Object] for (i = 0; i

For (VAR i = 1; i

Var browsername = navigator.appname; var isie = browsername.indexof ("Microsoft")! = - 1? true: false;

/ * Dynamic Build "Layer" * / Function JS_IO_SMARTINPUT_BUILDDIV () {document.write ("

"); Document.write ("
"); Document.write "
Parameter content intelligent input "); Document.write (" × "); Document.write (" "); document.write ("
"); Document.write (" "); Document.write (" "); Document.write (" "); var cal = document.GtelementByid (" MartInputdiv "); js_io_smartinput_hidediv (CAL);}

/ * Hidden "layer" * / function js_io_smartInput_hideDiv (cal) {cal.style.display = "none";} / * Display "layer" * / function js_io_smartInput_showDiv (obj) {var cal = document.getElementById ( "martInputDiv") ; var desTxtId = obj; cal.style.display = ""; vtop = js_io_smartInput_offsetTop (obj); vheight = obj.offsetHeight; vwidth = obj.offsetWidth; vleft = js_io_smartInput_offsetLeft (obj) vwidth; if (isIE) {if ( vtop cal.offsetHeight> document.body.scrollTop document.body.clientHeight) vtop = vtop vheight-cal.offsetHeight; if (vleft cal.offsetWidth> document.body.scrollLeft document.body.clientWidth) vleft = js_io_smartInput_offsetLeft (obj) -cal.offsetWidth; cal.style.top = vtop; cal.style.left = vleft;} else {if (vtop cal.offsetHeight> window.innerHeight) vtop vtop vheight-cal.offsetHeight =; IF (VLEFT CAL.OFFSETWIDTH> WINDOW.INNERWIDTH) VLEFT = JS_IO_SMARTINPUT_OFFSETLEFT (OBJ) - CAL.OffSetWidth; Cal.Style.top = Vtop; Cal.style.Left = VLEFT;}}

/ * From the length of the window layer is provided on the left * / function js_io_smartInput_offsetLeft (obj) {x = obj.offsetLeft; for (objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent) x = objParent.offsetLeft; return x;}

/ * Set length "layer" from the top of the window * / function js_io_smartInput_offsetTop (obj) {y = obj.offsetTop; for (objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent) y = objParent.offsetTop; return y; }

/ ** ----------------------------------------------- -------------------------------------------- * Visual effect control Function * ------------------------------------------------ ---------------------------------------------*//*the following Two functions are used in: Mouse is placed in a table, trigger dynamic visual effect * / // function a function js_io_smartinput_sbar (st) {var hightlightcolor = '# ff0000'; // "Highlight" color St.Style .BACKGROUNDCOLOR = HightlightColor;} // Function 2 function js_io_smartinput_cbar (st) {var lowligthcolor = '; // "Unchecked" Color St.Style.BackgroundColor = lowligthcolor;}

/ * Run: When the text box gets the input focus, the cursor is always in the last (tail) * / / * usage of text box (TEXT) * / / * Usage:

/ * Read data from cookie * / function JS_IO_SMARTINPUT_GETCOOKIE (KEY) {var saarch = key = "; var returnvalue =" = "; = {offset = document.cookie.indexof Search; if (Offset! = -1) {OFFSET = Search.Length End = Document.cookie.Indexof (";", Offset; if (end == -1) end = Document.cookie.length; ReturnValue = unescape (document.cookie.substring (offset, end))}} return returnvalue;!} / ** Clear uniquely identify the cookie * @param key Cookie ** / function js_io_smartInput_clearCookie (key) {if (js_io_smartInput_getCookie (key) = "") {Document.cookie = key "=";}}

转载请注明原文地址:https://www.9cbs.com/read-49873.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.045, SQL: 9