Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25969

Re: My 'actual' code

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: My 'actual' code
Date Tue, 21 Oct 2014 19:52:13 +0100
Organization A noiseless patient Spider
Lines 67
Message-ID <87r3y16ysi.fsf@bsb.me.uk> (permalink)
References <calc4vFrm5iU1@mid.individual.net> <can8usFboljU1@mid.individual.net> <caniujFef23U1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="28837"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dstdO//Pdfyg/zNl3NHblnkuLdrugQrA="
Cancel-Lock sha1:AzcVTyF84ZLczYF/QIUStt8nHpY= sha1:I3BcpGSb/+/QektO6xREu5F9IxU=
X-BSB-Auth 1.85d7b3689baf2b67bcd8.20141021195213BST.87r3y16ysi.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:25969

Show key headers only | View raw


"Mel Smith" <syntel@cox.net> writes:

>    FYI, below is the actual code I'm currently working on.

As is so often the case, the actual code shows an altogether different
way to do things that avoids the problems in the question as asked!

<snip>
> <snipped about 60 lines about in this func>
> //vars i,j are local vars from above of course
> // the values I'm gathering are single-char values in a 5 row, 23 column 
> input table, where there are only 18 input elements in each row.
> // As the user inputs single values, he is 'kicked' to the next element 
> (either verticall or horizontally), and the read-only fields in tge row are 
> updated
> // there will be five (for now) strings submitted to the server - one string 
> from each row
> **************************
> // now have to code the table for all internal values
>
> var hscells,ptcells,ftcells,dlcells,rlcells ;
> var hsstr,ptstr,ftstr,dlstr,rlstr ;
>
> hsstr = ptstr =  ftstr = dlstr =  rlstr = "" ;
>
> hscells = getobj("ihsrow").cells ;
> ptcells = getobj("iptrow").cells ;
> ftcells = getobj("iftrow").cells ;
> dlcells = getobj("idlrow").cells ;
> rlcells = getobj("irlrow").cells ;
>
> var allrows = [hscells,ptcells,ftcells,dlcells,rlcells] ;
> var allstrs = ["hsstr","ptstr","ftstr","dlstr","rlstr"] ;   // could use 
> .split() maybe

It looks like you've sliced an object into different variables.  I'd put
those objects back together again:

  var all = [
      { cells: getobj("ihsrow").cells,
        string: ""
      },
      { cells: getobj("ipsrow").cells,
        string: ""
      },
      { cells: getobj("ifsrow").cells,
        string: ""
      },
      { cells: getobj("idsrow").cells,
        string: ""
      },
      { cells: getobj("irsrow").cells,
        string: ""
      }
  ];

though I'd be tempted to build these using a function -- only one letter
is needed to create the different objects.

Now when you iterate through the array, you have the cells the string
you are building linked together.  No need to link them by a name and an
eval call (unless I've missed some key part from the code I cut -- I did
scan it in rather a hurry).

<snip code>
-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-20 15:11 -0600
  Re: JS Array problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-20 22:25 +0000
    Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:33 -0600
  Re: JS Array problem danca <cyberdanny@tiscalinet.it> - 2014-10-21 09:08 +0200
    Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:42 +0200
      Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 09:47 +0200
        Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:51 +0200
          Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 09:53 +0200
        Re: JS Array problem Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-21 09:52 +0200
          Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-21 10:36 +0200
      Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:36 -0600
    Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:35 -0600
      Re: JS Array problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-21 19:02 +0200
  Re: JS Array problem "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-10-21 13:12 +0200
    Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:38 -0600
  Re: JS Array problem "Mel Smith" <syntel@cox.net> - 2014-10-21 08:29 -0600
    My 'actual' code "Mel Smith" <syntel@cox.net> - 2014-10-21 11:20 -0600
      Re: My 'actual' code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-10-21 19:52 +0100
        Re: My 'actual' code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-21 21:23 +0200
  Re: JS Array problem Violet Deng <dengviolet@gmail.com> - 2014-10-28 02:03 -0700
    Re: JS Array problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-28 10:08 +0100

csiph-web