Connecting Tech Pros Worldwide Help | Site Map

value is null or not an object -- after a few submits

AC
Guest
 
Posts: n/a
#1: Jul 20 '05
This code works great the first few times it is used in a form and then I
get the error:
'QUANTITY.value' is null or not an object in IE6.

The names used are generated on the server so it is not code that changes
due to being handwritten. I can't see any reason why this does work at
first then fails after a few uses. It is weird that it works perfectly but
after a few attempts it stops working.


**THE CALLER:
note there are some hidden fields but they are not used in this code.
====================================
<tr>
<FORM NAME='frmOrder39ea'>
<td width='50' valign='middle' align='center'><font size=-1>
<input type='text' size='3' name='QUANTITY' value='0'
onChange='this.value=CKquantity(this.value)'></input>&nbsp;</font></td>
</FORM>

<FORM NAME='frmOrder39bx'>
<td width='53' valign='middle' align='center'><font size=-1>
<input type='text' size='3' name='QUANTITY'
value='0'></input>&nbsp;</font></td>
</FORM>


<FORM NAME='frmSubmitMe39'>
<td>
<input type="button" value="Buy"
onClick="ProcessBuys(document.forms['frmOrder39ea'],
document.forms['frmOrder39bx'])">
</td>
</FORM>
</tr>
====================================



**THE FUNCTON:
takes the two forms above and then works on them.
The line with the error is commented below.
====================================
function ProcessBuys(first, second) { //, second) { //Handles multiple items

//alert('1p- '+first.PRICE.value+' -1p 2p- '+second.PRICE.value+' -2p
1q- '+first.QUANTITY.value+' -1q 2q-'+second.QUANTITY.value+' -2q' );

if (! first){
alert('first object is null');
return false;
}
else {
if (first.QUANTITY.value!=null){ // <---- ERROR IS ON THIS LINE
if(first.QUANTITY.value>0){
AddToCart(first);
//alert('bye '+first.name+' bye');
}
}
else {
alert('first quantity is null');
}
}

if (second.QUANTITY.value!=null){
if(second.QUANTITY.value>0){
AddToCart(second);
//alert('abt '+first.name+' abt');
}

return false;
}

first=null;
second=null;

return true;
}
====================================
*****************************************


Richard Cornford
Guest
 
Posts: n/a
#2: Jul 20 '05

re: value is null or not an object -- after a few submits


"AC" <AC@No.spam> wrote in message
news:hw9Zb.59339$IF1.32281@nwrdny03.gnilink.net...
<snip>[color=blue]
> <tr>
> <FORM NAME='frmOrder39ea'>[/color]
<snip>

Valid HTML 4 requires (by official DTD) a form element to have an action
attribute and forms may not be children of TR elements. Without starting
with valid HTML there is no reason to expect javascript to be able to
interact successfully with the resulting DOM.

Richard.


AC
Guest
 
Posts: n/a
#3: Jul 20 '05

re: value is null or not an object -- after a few submits


So you're saying:

1) I need to have an action for the form. I can do that by creating an
action I won't use.

2) I can't have a form(s) in a table? Do you mean I should use CSS?

Thanks for the info. Could you supply some ideas about what I should change
the code to?


-AC

"Richard Cornford" <Richard@litotes.demon.co.uk> wrote in message
news:c13cks$p64$1$830fa78d@news.demon.co.uk...[color=blue]
> "AC" <AC@No.spam> wrote in message
> news:hw9Zb.59339$IF1.32281@nwrdny03.gnilink.net...
> <snip>[color=green]
> > <tr>
> > <FORM NAME='frmOrder39ea'>[/color]
> <snip>
>
> Valid HTML 4 requires (by official DTD) a form element to have an action
> attribute and forms may not be children of TR elements. Without starting
> with valid HTML there is no reason to expect javascript to be able to
> interact successfully with the resulting DOM.
>
> Richard.[/color]


Robert
Guest
 
Posts: n/a
#4: Jul 20 '05

re: value is null or not an object -- after a few submits


> 2) I can't have a form(s) in a table? Do you mean I should use CSS?[color=blue]
>
> Thanks for the info. Could you supply some ideas about what I should change
> the code to?
>[/color]

I believe the poster is saying that you need to construct a proper table:

Data is in <td> tags not <tr> tags. Try:

<tr>
<td width='50' valign='middle' align='center'>
<FORM NAME='frmOrder39ea'>
....
<form>
</td>
</tr>

I not sure how reliable the font tag is across tables.

Robert
AC
Guest
 
Posts: n/a
#5: Jul 20 '05

re: value is null or not an object -- after a few submits


I updated the pages to be HTML 4 compliant as far as I know it did nothing
to help.

Reposting this with the new compliant code and hoping someone can solve
this.

-AC

"Robert" <rccharles@my-deja.com> wrote in message
news:c6bb75ff.0402192122.7e460051@posting.google.c om...[color=blue][color=green]
> > 2) I can't have a form(s) in a table? Do you mean I should use CSS?
> >
> > Thanks for the info. Could you supply some ideas about what I should[/color][/color]
change[color=blue][color=green]
> > the code to?
> >[/color]
>
> I believe the poster is saying that you need to construct a proper table:
>
> Data is in <td> tags not <tr> tags. Try:
>
> <tr>
> <td width='50' valign='middle' align='center'>
> <FORM NAME='frmOrder39ea'>
> ...
> <form>
> </td>
> </tr>
>
> I not sure how reliable the font tag is across tables.
>
> Robert[/color]


Robert
Guest
 
Posts: n/a
#6: Jul 20 '05

re: value is null or not an object -- after a few submits


> ====================================[color=blue]
> <tr>
> <FORM NAME='frmOrder39ea'>
> <td width='50' valign='middle' align='center'><font size=-1>
> <input type='text' size='3' name='QUANTITY' value='0'
> onChange='this.value=CKquantity(this.value)'></input>&nbsp;</font></td>
> </FORM>
>
> <FORM NAME='frmOrder39bx'>
> <td width='53' valign='middle' align='center'><font size=-1>
> <input type='text' size='3' name='QUANTITY'
> value='0'></input>&nbsp;</font></td>
> </FORM>
>
>
> <FORM NAME='frmSubmitMe39'>
> <td>
> <input type="button" value="Buy"
> onClick="ProcessBuys(document.forms['frmOrder39ea'],
> document.forms['frmOrder39bx'])">
> </td>
> </FORM>
> </tr>[/color]

I hadn't look at this carefully before but you realize that you have
three forms here?

Each form requires an action tag that I do not see. I assume that
each form requires a button. I assume the three forms should be one.

I suggest reviewing the html input source. Find an expert on HTML.

You may want to take a look at:
http://tidy.sourceforge.net/

Robert
AC
Guest
 
Posts: n/a
#7: Jul 20 '05

re: value is null or not an object -- after a few submits


"Robert" <rccharles@my-deja.com> wrote in message
news:c6bb75ff.0402201125.1f29b163@posting.google.c om...[color=blue][color=green]
> > ====================================[/color][/color]
<snip/>[color=blue]
>
> I hadn't look at this carefully before but you realize that you have
> three forms here?
>
> Each form requires an action tag that I do not see. I assume that
> each form requires a button. I assume the three forms should be one.
>
> I suggest reviewing the html input source. Find an expert on HTML.
>
> You may want to take a look at:
> http://tidy.sourceforge.net/
>
> Robert[/color]

Thank you for your replies.

Yes I know. I am using an application called NOPcart v4.2.2
(http://www.nopdesign.com/freecart) for the base and then I modified it a
bit. So I really have 3 forms per product. Which means up to about 150
forms per page :)

I have created a new post "value is null or not an object -- after
submitting a few times" with the cleaned up code. I didn't think this
thread would get any more attention :(

I will look at Tidy.

Thanks,
-AC


Closed Thread