Click to See Complete Forum and Search --> : objects of fustration


azz
04-09-2003, 06:24 AM
Hi there,

OK, here's the thing - this is one of those bash-your-head-against-the-problem-until-it-bleeds kinda things.

I have a page that gives the user a packing checklist - the user selects items from the list and clicks the I'm Packed button - a newpage is then generated with the items that were selected so that they can print it out.

I use an array of objects with two properties, ffName (the checkbox name) and text (the value to be written in the new page), and a method to write the text property to the file. The idea is that I iterate through the array, compare the form element with the name stored in ffName to see if it's checked or not, and then invoke the write method if neccessary.

This is the loop:
for(i=0; i< itemArray.length; i++)
{
if (formDOM.elements[itemArray[i].ffName].checked == true)
{ itemArray[i].writeToDoc(); }
}

looks pretty straightforward, no?

Now - here's the thing. For some reason IE on my PC opens the page but doesn't print out the list. Using the Netscape 7 javascript window, it tells me that the array that I define to hold my list objects is undefined.
IE on my Mac is a little more specific - it does write the list - up to array item 18 and then returns an error 'formDOM.elements[..].checked is not an object' :confused:

I really don't know what's going on here. Any ideas anybody?

check out

http://www.tntmagazine.com/uk/newHomePageSet/tguide/travelChoice.asp?guideId=packing

for the full page code (rather large page - problem area in script btw lines 405 and 472) - attached a code snippet to this post as well

Sorry for the REALLY long post, but had to get the whole problem out there. Hope you guys can help!

Cheers,

azz

azz
04-09-2003, 07:53 AM
Thanks for the aid, mate.

I've tried doing this:

function generateList()
{
var pageList = ''
var head = '<html><head><title>tntmagazine.com - find a job | get a flat | book a flight and more...</title><link rel="stylesheet" type="text/css" href="/uk/autostyle.css"></head><body><h2>Packing checklist</h2>provided by tnt-live.com<br><a href="http://www.tnt-live.com/">http://www.tnt-live.com/</a><br><br>'
var tail = '<p><button type="submit" value="Print" onClick="Javascript:print()">Print</button>&nbsp;&nbsp;<button type="submit" value="Back" onClick="javascript:history.go(-1)">Back</button></p></body></html>'

formDOM = document.list

// open window and write heading
//alert(itemArray.length);
// write objects

counter = 0;
while(counter < itemArray.length)
{ formFieldName = itemArray[counter].ffName
if (formDOM.elements[formFieldName].checked == true)
{ pageList = pageList + '<input type="checkbox"> ' +itemArray[counter].text+'<br>' }

counter++;
}

//write eof and close input stream

document.open();
document.write(head);
document.write(pageList);
document.write(tail);
document.close();

}

But now it's just giving me the error (same as before) and not opening the page.

Any ideas?

Cheers

Azz

azz
04-09-2003, 07:57 AM
Even wierder!!

Just tested that code in the IE environment on pc and it tries to pass the values selected in the URL:

http://www.tntmagazine.com/uk/newHomePageSet/tguide/travelChoice.asp?FirstAidKit=FirstAidKit&BandAids=BandAids&Smallscissors=smallscissors&Submit=I%27m+packed%21

What????

hmmm ...

something very screwy here

Azz

azz
04-10-2003, 01:44 AM
Really?

OK - I just assumed as I was opening the input string and closing the input string that I could put any number of commands between the two. It doesn't work like that?

Thanks for the aid - I'll give it a go. As you probably have gathered from my post in the ASP section, I'm also trying to think of a way to break own and rebuild the page in ASP. I think that might be a way forward, but I'll definately give this a go - Thanks

Cheers

Azz