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

A

AC

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;
}
====================================
*****************************************
 
R

Richard Cornford

<tr>
<FORM NAME='frmOrder39ea'>
<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.
 
A

AC

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
 
R

Robert

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?

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
 
A

AC

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
 
R

Robert

====================================
<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>

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
 
A

AC

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top