Hi Folks
I have a problem that really has me stumped
If you can please have a look at http://oldbusman.co.nz/productDetails.cfm?ID=9
the "add to Cart' table has an up/down arrow to adjust the quantity being ordere, and this has a function in the page to stop it going any lower than 1.

My Problem
When i now try and run this page on my local machine and click the "up" arrow to increase the number i gat an error that shows NaN in the quantity field.
I have also copied this page and saved it in another site i am building using a cart and when i try and run that page in the new site i get an 'error on Page' in the status bar
This error is telling me:

Message: 'document.forms.0.quantity.value' is null or not an object
Line: 19
Char: 4
Code: 0
URI: http://localhost:8500/foxtonrv/productDetails.cfm?ID=2

Following is the code for the function and the "add to cart" table from my page
Function:

<!---sPIN BUTTONS TO UP QUANTITY with a minimum value of 1--->
<script type="text/javascript">
function changeVal(n) {
            if(document.forms[0].quantity.value ==1 && n ==-1)
            {
            return;
            }
            document.forms[0].quantity.value =parseInt(document.forms[0].quantity.value) + n;
            }
            </script>

and my table code:

                <table cellpadding="0" cellspacing="0" style="border:0px solid #cccccc;">
                  <tr>
                    <td height="26" class="smalltext"><span class="smalltext11Light">Add</span> </td>
                    <td ><input name="quantity" type="text" class="quantity" value="1" onFocus="this.blur();" ></td>
                    <td style="width:14px;">
                    <table cellpadding="0" cellspacing="0">
                   <td width="28"><img src="siteImages/btn_up.gif" width="14" height="9" hspace="0" vspace="0" border="0" onClick ="changeVal(1);"></td>
                  </tr>
                  <tr>
                 <td><img src="siteImages/btn_down.gif" width="14" height="9" border="0" hspace="0" vspace="0" onClick ="changeVal(-1);"></td>
                 </tr>
                  </table>
                   <td class="smalltext" style="width:120px;"><span class="smalltext11Light"> of this item to my Cart: </span>                        
                      <td style="width:50px;"><input type="submit" name="btn_add" id="btn_add" class="smalltext11Light" value="Add to Cart">
                  </table>
                <input name="ID" type="hidden" id="ID" value="<cfoutput>#productdetail.ID#</cfoutput>">
                <hr size="1"  noshade color="#003366"></td>
          </tr>
        </form>
        </table>

The only thing i have done to my machine since i made that 'oldbusman' page is upgrade from an oem 64bit version of windows 7 to a full copy of win7x64bit

Could this have something to do with a setting in ie8 or if not can anyone PLEASE help me with this problem

Cheers and thanks in advance
Grabit

Thanks to you all

Member Avatar for stbuchok

use document.getElementById('quantity') instead

Grabit,

The page has major structural problems.

It has several <!DOCTYPE>s, each with its own <html><head>...</head><body>...</body></html> structure. There's also a <tittle> above the first <!DOCTYPE>. Various blocks of markup/javascript/css are repeated in each structure.

It looks like the page is pulled together by including a bunch of self-contained web pages rather than a bunch of fragments. Other pages in the site are similarly constructed.

This is certainly not in accordance with W3C recommendations and probably enough to confuse some browsers.

There should be one <!DOCTYPE> at the very top of the document and one <html> etc. structure beneath it.

You really must fix this before doing ANYTHING ELSE.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.