Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: My (so-called) solution Date: Thu, 18 Jul 2013 09:50:13 -0600 Lines: 128 Message-ID: References: <1rqamz10aphh7$.yzerntlnqpx2.dlg@40tude.net> X-Trace: individual.net bPi8h9rK4vHP774YXI7fhAqXlI3+20I+/CRas6OkOjTUPgFdQJ Cancel-Lock: sha1:Pnx7pokWtJuG78GDt77WpBDIYO4= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: csiph.com comp.lang.javascript:20697 JJ said: > Are you trying to create an Excel-like table? Hi JJ: I 'may' be treating this like excel -- but I've never used Excel, except to dump stuff into a database, but YES, I wish to create an easily navigable and editable table. To review: - I have a 13-column table with the six columns on the far right easily traversible and 'editable'. - The number of rows is variable and unpredictable and modifiable by the user. - Currently, there are approx 19000+ pages that are available for editing. - Column 1 on the far left of the data rows is a button that says: 'Delete this Row'. - Column 1 in the header row has a button that says 'Add a New Row'. - Columns 2 thru 7 are readonly and mirror the editable columns 8 thru 13. - All editable cells have a tabIndex with the root index at 201 and extending left to right and then down thru the rows. - Every time a row is inserted or deleted, I rebuild the tabIndexes for all editable cells. - I also build /rebuild two arrays (1)- Holds editable objects, and (2) Holds the associated tabIndex for the Object - I access the index array (2) looking for the next tabIndex, then pick out the associated object to focus on next. I want to have my editable cells easily navigable thru using the following keys: ,, , , ,, ,. On each keydown, I 'listen' for these movement keys above, then I access the two functions shown below: Finally, this is working fine right now, and I don't need IDs to navigate My next step is to validate the input values in each of the 6 editable columns. I'll do this *whenever* the user leaves an editable cell Thanks for your guidance ! -Mel Smith ****************************************** function getnextobj(elindex,elname,nextdir,currobj) { var nextindex,nextobj,nval,latleftcol,latrightcol ; nextobj = currobj ; // default object nextindex = elindex ; // un-declared vrbls below are defined at the global level for // other functins to access // now search thru the aobjs and aindexes for the *next* index switch (nextdir) { case "goup" : nextindex = elindex - numcols ; break ; case "godown" : nextindex = elindex + numcols ; break ; case "gofwd" : nextindex = elindex + 1 ; break ; case "gobak" : nextindex = elindex - 1 ; break ; case "gohome" : while (nextindex > mintab) { // move left to first column nval = nextindex - (mintab-1) // e.g., 210 - (201-1) is 10 latleftcol = ((nval % numcols) === 1 ) ? true : false ; if (latleftcol) break ; nextindex-- ; } break ; case "goend" : while (nextindex < maxtab) { // move right to last column nval = nextindex - (mintab-1) // e.g., 210 - (201-1) is 10 latrightcol = ((nval % numcols) === 0 ) ? true : false ; if (latrightcol) break ; nextindex++ ; } break ; case "gopgup" : while (nextindex >= (mintab+numcols) ) { nextindex -= numcols ; } break ; case "gopgdn" : while (nextindex <= (maxtab-numcols) ) { nextindex += numcols ; } break ; } if (nextindex < mintab || nextindex > maxtab) return nextobj ; nextobj = srchobjs(nextindex,nextobj) ; // using default nextobj return nextobj ; } function srchobjs(nindex,oldobj) { var i,nextobj ; var nlen = aobjs.length ; for (i=0;i < nlen;i++) { // loop for next index to focus on if (aindexes[i] === nindex) { nextobj = aobjs[i] ; // get the object with the correwct index return nextobj ; // this is the next object to focus on } } return oldobj ; } ****************************************