By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

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

P: n/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;
}
====================================
*****************************************
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"AC" <AC@No.spam> wrote in message
news:hw*******************@nwrdny03.gnilink.net...
<snip>
<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.
Jul 20 '05 #2

P: n/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

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c1*******************@news.demon.co.uk...
"AC" <AC@No.spam> wrote in message
news:hw*******************@nwrdny03.gnilink.net...
<snip>
<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.

Jul 20 '05 #3

P: n/a
> 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
Jul 20 '05 #4

P: n/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

"Robert" <rc*******@my-deja.com> wrote in message
news:c6**************************@posting.google.c om...
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

Jul 20 '05 #5

P: n/a
> ====================================
<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
Jul 20 '05 #6

P: n/a
AC
"Robert" <rc*******@my-deja.com> wrote in message
news:c6**************************@posting.google.c om...
====================================
<snip/>
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
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.