Email lists > 1stJavaScript > RE: [1stJavaScript] Re: java array won't fill more then two rows. > RE: [1stJavaScript] Re: java array won't fill more then two rows.

RE: [1stJavaScript] Re: java array won't fill more then two rows.




This post if a part of  this thread

2008-07-03 02:51:08
RE: Re: java array won't fill more then two rows.

The problem is with the way you're defining the arrays. You need to use this
syntax br>
var mArray = new Array();

var mArray[0] = new Array();
mArray[0][0] = "some text";

var mArray[1] = new Array();
mArray[1][0] = "more text";

You should also use an indicator in your PHP code to determine if the
<script> tags are active, so that you're not constantly turning them on and
off, as this will have a serious overhead when loading the page.

Rob.

-----Original Message-----
From: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com [mailto: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com] On
Behalf Of Stone
Sent: 02 July 2008 16:38
To: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com
Subject: [1stJavaScript] Re: java array won't fill more then two rows.

here is what the source of the webpage shows is being loaded into the
java array:

<script type='text/javascript'>var mArray = new Array(new Array(),
new Array()); var num_rec='4';</script><;script
type='text/javascript'>mArray['0']['0'] = '1';</script>&lt;script
type='text/javascript'>mArray['0']['1'] = 'Good Will
Hunting';</script><script type='text/javascript'>mArray['0']['2']
= 'Drama';&lt;/script&gt;<script type='text/javascript'>mArray['0']['3']
= 'Home';<;/script>;<script type='text/javascript'>mArray['0']['4']
= 'Matt Damon, Robin Williams, Ben Affleck, Minnie Driver, Stellan
Skarsgard';</script>&lt;script type='text/javascript'>mArray['0']['5']
= 'Matt Damon and Ben Affleck won an Oscar for their script about
friendship and risk for this film directed by Gus Van Sant. With an
abuse-filled past and a janitorial job, Will Hunting (Damon) spends
his days hanging out with best friend Chuckie Sullivan (Affleck). But
the aimless young man's also a mathematical genius, and when his
talents are discovered, a therapist (Robin Williams) helps Will
confront the demons that have been holding him
back.';</script><script type='text/javascript'>mArray['0']['6']
= '1997';<;/script>;<script type='text/javascript'>mArray['0']['7']
= 'United States';&lt;/script&gt;<script type='text/javascript'>mArray['0']
['8'] = '1';</script>&lt;script type='text/javascript'>mArray['0']['9']
= '89';</script><script type='text/javascript'>mArray['0']['10']
= '';</script>&lt;script type='text/javascript'>mArray['0']['11']
= 't';</script>&lt;script type='text/javascript'>mArray['1']['0']
= '2';</script>&lt;script type='text/javascript'>mArray['1']['1']
= 'Good Morning Vietnam';&lt;/script&gt;<script
type='text/javascript'>mArray['1']['2']
= 'Comedy/Drama';</script><script type='text/javascript'>mArray['1']
['3'] = 'Home';<;/script>;<script type='text/javascript'>mArray['1']
['4'] = 'Robin Williams, Forest Whitaker, Tung Thanhtran, Bruno
Kirby, Robert Wuhl';</script><script type='text/javascript'>mArray
['1']['5'] = 'When his manic radio show proves a colossal morale-
booster, Armed Forces Radio deejay Adrian Cronauer (Robin Williams)
gets sent to Vietnam. His monkeyshines -- lampooning any and all
sacred cows -- tickle the troops but land him in hot water with his
superiors, who'd like the broadcast to be sanitized and
uncontroversial. Then, after encountering war's horror firsthand,
Cronauer makes the egregious mistake of telling his audience the
truth. ';</script><script type='text/javascript'>mArray['1']['6']
= '1987';<;/script>;<script type='text/javascript'>mArray['1']['7']
= 'United States';&lt;/script&gt;<script type='text/javascript'>mArray['1']
['8'] = '1';</script>&lt;script type='text/javascript'>mArray['1']['9']
= '90';</script><script type='text/javascript'>mArray['1']['10']
= '';</script>&lt;script type='text/javascript'>mArray['1']['11']
= 't';</script>&lt;script type='text/javascript'>mArray['2']['0']
= '3';</script>&lt;script type='text/javascript'>mArray['2']['1']
= 'Sneakers';</script><script type='text/javascript'>mArray['2']['2']
= 'Suspense/Thiller/Mystery';<;/script>;<script
type='text/javascript'>mArray['2']['3'] = 'Home';<;/script>;<script
type='text/javascript'>mArray['2']['4'] = 'Robert Redford, Sidney
Poitier, Dan Aykroyd, David Strathairn, River
Phoenix';</script><script type='text/javascript'>mArray['2']['5']
= 'Shadowy U.S. intelligence agents blackmail Robert Redford and his
eccentric team of security experts into stealing a code-breaking
black box from a Soviet-funded genius. But Redford uncovers a bigger
conspiracy, and he and his sneakers (Sidney Poitier, Dan Aykroyd,
River Phoenix and David Strathairn) must save themselves and the
world economy by stealing the box back from the
blackmailers.';&lt;/script&gt;<script type='text/javascript'>mArray['2']
['6'] = '1992';<;/script>;<script type='text/javascript'>mArray['2']
['7'] = 'United States';&lt;/script&gt;<script type='text/javascript'>mArray
['2']['8'] = '1';</script>&lt;script type='text/javascript'>mArray['2']
['9'] = '91';</script><script type='text/javascript'>mArray['2']
['10'] = '';</script>&lt;script type='text/javascript'>mArray['2']['11']
= 't';</script>&lt;script type='text/javascript'>mArray['3']['0']
= '4';</script>&lt;script type='text/javascript'>mArray['3']['1'] = 'The
Sting';</script><script type='text/javascript'>mArray['3']['2']
= 'Suspense/Thiller/Mystery';<;/script>;<script
type='text/javascript'>mArray['3']['3'] = 'Home';<;/script>;<script
type='text/javascript'>mArray['3']['4'] = 'Paul Newnam, Robert
Redford';</script><script type='text/javascript'>mArray['3']['5']
= 'Fueled by ragtime music, The Sting takes the thrill of the
confidence game to giddy heights. After rookie grifter Johnny Hooker
(Robert Redford) tracks down veteran flim-flam man Henry Gondorff
(Paul Newman) in 1930s Chicago, the duo plans to fleece a homicidal
racketeer (Robert Shaw) through a phony racetrack scam. Ripe with
double and triple crosses, The Sting keeps viewers guessing (and
yearning for another Newman-Redford seriocomic
teaming).';</script>&lt;script type='text/javascript'>mArray['3']['6']
= '1973';<;/script>;<script type='text/javascript'>mArray['3']['7']
= 'United States';&lt;/script&gt;<script type='text/javascript'>mArray['3']
['8'] = '1';</script>&lt;script type='text/javascript'>mArray['3']['9']
= '92';</script><script type='text/javascript'>mArray['3']['10']
= '';</script>&lt;script type='text/javascript'>mArray['3']['11']
= 't';</script>&lt;script type='text/javascript'>var dArray = new Array
(new Array(), new Array());&lt;/script&gt;
<form name=";movies&quot;>

--- In 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com, "Atkinson, Robert&quot;
<ratkinson...> wrote:
&gt;
> Please can you paste the HTML page, rather than the PHP source.
>
> -----Original Message-----
> From: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com
[mailto: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com] On
> Behalf Of Stone
&gt; Sent: 01 July 2008 22:10
&gt; To: 1stJavaScript%40yahoogroups.com">1stJavaScriptyahoogroups.com
> Subject: [1stJavaScript] java array won't fill more then two rows.
&gt;
> I am trying to create a form on a webpage and i am using PHP to
connect
> to a SQL database, running a query, and putting the results into a
java
> array to be used for client side scripting.
>
> it works just fine for two rows but then anymore and it gives the
error
> mArray[...].1 is null or not an object or mArray1. is null or not
an
> object.
>
> when i look at the source of the webpage it shows each line being
added
> to the array and that shows it as being added correctly. below is
the
> code i have to fill the array.
>
> any help would be very much appreciated.
>
> //Create array in java
>; echo "<script type='text/javascript'>var mArray = new Array(new
Array
> (), new Array());&lt;/script&gt;";
> $i = 0;
>
> //Fill the array
&gt; while($arr = pg_fetch_row($result)) //creates array from row in
query
> {
> for ($j=0; $j<$cNum; $j++)
> {
> //takes each collom and puts it into correct row and
> collum of java array
&gt; echo "<script type='text/javascript'>mArray['$i']
['$j']
> = '$arr[$j]';</script>";;
> }
> $i++;
> }
>
>
> ------------------------------------
&gt;
> For a quick response, your message should include,
>
> - A copy of the code
>; - A copy of any error messages
> - A description of what you're trying to achieve
> - A description of what's actually happening
>
http://www.trans4mind.com/personal_development/HTMLGuide/index.html
For HTML
>;
http://www.trans4mind.com/personal_development/JavaScript/index.html
For
&gt; JavaScript
> You can also download the JavaScript and HTML tutorials (Nearly 2.5
> megabytes.)
> A 30 day version of jsEditor is available for free download at
>
http://www.trans4mind.com/personal_development/JavaScript/freeEditor.h
tm
>; --------------------------
&gt; FREE zip/unzip program:
> http://www.trans4mind.com/personal_development/zipper/index.html
> --------------------------OR go to and change your settings:
> http://groups.yahoo.com/group/1stJavaScript/
>; List owner: 1stJavaScript-owner%40yahoogroups.com">1stJavaScript-owneryahoogroups.com
>
>
> ://groups.yahoo.com/group/1stJavaScript/
> List owner: 1stJavaScript-owner%40yahoogroups.com">1stJavaScript-owneryahoogroups.com
>
>
> Yahoo! Groups Links
&gt;
>
>
>
>
**********************************************************************
*************
> Any opinions expressed in email are those of the individual and not
necessarily those of the company. This email and any files
transmitted with it are confidential and solely for the use of the
intended recipient
> or entity to whom they are addressed. It may contain material
protected by attorney-client privilege. If you are not the intended
recipient, or a person responsible for delivering to the intended
recipient, be advised that you have received this email in error and
that any use is strictly prohibited.
>
> Random House Group + 44 (0) 20 7840 8400
>; http://www.randomhouse.co.uk
> http://www.booksattransworld.co.uk
> http://www.kidsatrandomhouse.co.uk
>; Generic email address - enquiries...
>;
> Name & Registered Office:
> THE RANDOM HOUSE GROUP LIMITED
> 20 VAUXHALL BRIDGE ROAD
>; LONDON
&gt; SW1V 2SA
> Random House Group Ltd is registered in the United Kingdom with
company No. 00954009, VAT number 102838980
>
**********************************************************************
*************
>

------------------------------------

For a quick response, your message should include,

- A copy of the code
- A copy of any error messages
- A description of what you're trying to achieve
- A description of what's actually happening
http://www.trans4mind.com/personal_development/HTMLGuide/index.html For HTML
http://www.trans4mind.com/personal_development/JavaScript/index.html For
JavaScript
You can also download the JavaScript and HTML tutorials (Nearly 2.5
megabytes.)
A 30 day version of jsEditor is available for free download at
http://www.trans4mind.com/personal_development/JavaScript/freeEditor.htm
--------------------------
FREE zip/unzip program:
http://www.trans4mind.com/personal_development/zipper/index.html
--------------------------OR go to and change your settings:
http://groups.yahoo.com/group/1stJavaScript/
List owner: 1stJavaScript-owner%40yahoogroups.com">1stJavaScript-owneryahoogroups.com

://groups.yahoo.com/group/1stJavaScript/
List owner: 1stJavaScript-owner%40yahoogroups.com">1stJavaScript-owneryahoogroups.com

Yahoo! Groups Links

__._,_.___
.

__,_._,___

about | contact  Other archives ( Real Estate discussion Medical topics )