DOCUMENTATION ON HTML [B] A) DOCforms also contains basic HTML doc on
s; It is mainly about my php support for serverside forms: using php to process incoming queries, and using forms to elicit that input from users. B) DOCformsJava is about client-side manipulation of forms, mainly to send queries to other servers from me. ========== ========== ========== ========== A] Philosophy / basic underlying approach for using java ----- ----- ----- ----- ----- ? ========== N.B. java: The Java philosophy is not to store things in Java globals, but to use java-accessed attributes of the HTML DOM tree elements to store things. Including adding whole new elements from java if necessary. However better to create the elements in HTML, and hide them as required: by type=hidden, or by display: none. You can use java in browser to re-edit the FORMs extensively: change method, actionURL, var values etc. So a possible approach is to have a basic dummy form in HTML; get user i/p; then on-click on various buttons, do calcs, set new values into form, and exec it. Adding spurious fields to an HTML tag does NOT create new fields in the java DOM object. (But can use HTML additions to a tag to set fields in the java object if pre-defined.) ========== ========== ========== ========== B] DOC. ON STD. HTML/BROWSER INSTANTIATION OF FORMs. ----- ----- ----- ----- ----- FORM.action: action="javascript:" seems to be the only null action. Adding query args to the 'action': overwritten if GET; passed if POST (but receiver shouldn't look at them, though they are there in PHP). Cannot use action="javascript:shiftdata(this);" for a FORM to pass a ptr to the form, because 'this' refers to the window (?!) not the form. Sol1: use onclick="javascript:fn(this)" etc. for form or btn. or i.e. do the real action from a form-element, not from the form. BUT must spec. an action for the form, even when not useful. SO: action="javascript:" seems to be the only null action. Sol2: don't rely on 'this', but pass ptr to FORM or have the fn re-find FORM by name. ======= JAVA notes for FORMs Can use java to change the name of an element (the value of name=...); and that changed name is used to form query string (newvarname=val&...). However the compiled javascript code remembers the old name so that "myform.oldname" still works. So can use java to reprogram the HTML-given INPUT elements; and particularly to set name to null and so suppress a var being returned in the query string. Cycle over a FORM's INPUT elements (form.elements[]; test if nodeName==INPUT or myform.getElementsByTagName("input"); ), test if any val, if not then zero the name; else restore the name (?from the id?, the title?). There's no built in java fn. to calculate the query string a form will return; but can google-find code for function serialize() that will traverse DOM of and build it. document.cookie: Holds one string, with all cookies concatenated (';' separator?) document.forms: array onsubmit event. ** Basically: onsubmit event is NOT triggered by java-submit(); only by direct UI actions on the form (submit buttons pressed; in text input). But can easily do formptr.onsubmit(); formptr.submit(); in your code. (This allows a script for onsubmit to call submit() w/o causing infinite loop. Onsubmit will cause real submit iff it returns true. [check this; or only in ??] ) ======= ======= ======= ======= ======= ======= PROVIDING EXTENDED FUNCTIONALITY FOR UID OFFERED BY FORMS My main examples of these are in search.php Basic application for such extended fns: creating a page to collect user input and send to a server. Perhaps giving a better/different UID than that server offers. Besides designing the FORMs differently (to the way the server-author offers), we could use Java to further improve the UID facilities. The main approach is to nevertheless use HTML/DOM elements to hold the state, and dispatch to the server. But here are a list of extended functions wanted, and how I've implemented them. A. Use hidden vars as required to rep. and submit any var=vals needed by the application. In Java we can set/unset any such values, and indeed change the 'name' i.e. var. However: perhaps I should rep. all such cases not as 'type=hidden', but by checkboxes, greyed out ('disabled') so they can't be changed by user but are visible. Have the labels done by Java to show the var=val being sent; and refreshed as necessary if I use Java to change them. B. Clickability for text labels associated with each radio button. Basically, bind button and label by a containing DOM tag e.g. or ; and have an onclick-fn attached to that DOM that takes 'this' (so can have same fn. for every button), drills down to required button, and sets its 'checked'. B.v2) Better if fn. can recursively descend in case target button is enclosed in

or something. B.v3) Better still if it returns an array, not stops at the first. Then the mechanism can click multiple radio buttons tied to one label / set / row. C. Controlling multiple vars for query string from a single set of radio buttons. (E.g. in google: restricting search by domain and by country don't make sense as independent constraints.) Method is to represent every var in a sep. set of radio btns: one set per column, and one row per semantically valid alternative. Extend method [B] so that clicking on any part of a row checks all the radio buttons in that row, whether visible or not. D. Clean up returned vars for query string: don't return vars with null values. onSubmit=fn that searches over the form's inputs, and any with null 'value' has its 'name' set to null (which suppresses it), else its name reinstalled from (say) the ID field. E. Allow a radio button option to be a text input box: so most options are common fixed ones, and another one is 'other' and user types in the value. Method is onkeyup=fn so that every keystroke in the box copies the value from the box to the button's 'value'. E2. Onclick=fn installed on all the other radio options causes the value of that option to be copied down to the textbox for the 'other' radio option. F. Onclick on an input box causes, if box empty, a starting text string value to be copied in (sucked) from some other box. G. A submit button on one form can jump to another form. The button's submit function is suppressed; onclick=fn in the button runs a function to copy across a search string from first to second form; then does submit() on the second form. G2. May also use submission to another form as a sign to change (e.g.) var sitesearch for the future. Currently I do this by calling a fn. to do the switch in the onclick for the button, before calling the main functions of that btn. to switch to another form. H. There can be problems with 'backpage' browser button, if some button or other action uses java to change values away from their original values. You get problems because these values are now invisible, but not restored when 'backpage' is done. The solution is not to do that: to stick to using HTML /DOM objects to rep. vars and values; and not to go changing values that aren't rep. visibly (like which btn is selected). [C] could be a problem with this: so it must be self-re-initialising i.e. restore names, and be run every time. I. ?Windows. How to open, size, ... Problem is to have one submit open several windows? J. x ========== ========== ========== ========== X] Offset, focus, scrollto ----- ----- ----- ----- ----- The std. thing is to use java on Init to move focus, select, and scroll point to show a text input box. Select() will highlight text in the box. To get scrolling to it, though, have to use window.scrollTo(x, y); To put an object at top,left of vis. window just use the objects' positions: scrollTo(ptr.offsetLeft, ptr2.offsetTop); To show the context a bit more, crawl the DOM to the object's enclosing object. To show its text context, may want its previous HTML object, which is its .previousSibling; OR: use anchors: set id of enclosing object as target-dest. id = 'anchorname' exec location.hash = '#place3'; See my "search.php" [search console] for my most advanced practice on this. Should change my model sf().