[Javascript] Help to debug this

Marcelo Wolfgang grillo at gmail.com
Wed Aug 16 21:25:34 CDT 2006


Hi Paul,

well, I'm developing this page at the moment, it's much bigger than
only this snippet I post, I'm uploading it to avoid posting js on the
list again

you can check it out at www.work.grillo.tk/gaiolla/index.cfm?storeOwner=paula

I've added some alert()'s .. I thing I'm having problem with
getElementById, like it's not working .. is it possible ?

another script I have on the page minheight_iefix.js wich worked
earlier, is not working also, in Firefox error console it's says that
adjustHeight is not defined

which is the same error I'm getting for getElementById

Error: getElementById is not defined
Source file: http://lazy/gaiolla/index.cfm?storeOwner=paula#
Line: 45

Any clue ?

On 8/16/06, Paul Novitski <paul at juniperwebcraft.com> wrote:
> At 04:51 PM 8/16/2006, Marcelo Wolfgang wrote:
> >Can someone here please tell me why nothing happens in the above code ?
> >
> ><script type="text/javascript">
> >         function
> > addToCart(catalogID){
> > window.location='cart.cfm?act=add&storeOwner=paula&item_id='+catalog.ID+'&prodSize='+getElementByID(prodSizeSelect).value+'&prodColor='+getElementByID(prodColorSelect).value;
> >         }
> ></script>
> >
> >Here's the HTML:
> >
> ><div id="prodDescription">
> >         <div id="prodDesc-size">
> >                 <div id="prodSize-dropdown">
> >                         <select id="prodSizeSelect" name="prodSize">
> >                                 <option value="P">P</option>
> >                                 <option value="M">M</option>
> >                                 <option value="G">G</option>
> >                         </select>
> >                 </div>
> >         </div>
> >         <div id="prodDesc-color">
> >                 <select id="prodColorSelect" name="prodColor">
> >                    <option value="dourado">dourado</option>
> >                   <option value="uva">uva</option>
> >                  <option value="preto">preto</option>
> >               </select>
> >         </div>
> >         <div id="prodDesc-addToCart"><a href="##"
> >onClick="document.getElementById('item-added').className='show';addToCart(5);">Colocar
> >no carrinho<img src="images/prodaddCart_icon.gif" width="16"
> >height="16" alt="Colocar no carrinho" /></a></div>
> ></div>
> >
> >Can anyone tell me what I'm doing wrong here ?
>
>
> I can see a couple of things:
>
> 1) There is no element with the id "item-added" so the 'Colocar no
> carrinho' onlick event will fail.
> 2) getElementByID should be getElementById
> 3) getElementByID(prodSizeSelect) should be getElementById("prodSizeSelect")
> 4) getElementByID(prodColorSelect) should be getElementById("prodColorSelect")
>
> I recommend that you separate your HTML and your javascript instead
> of including your javascript inline.  Also, if you break your long
> statements into shorter steps, it will be easier to debug.
>
> I would also like to suggest that giving us a link to a complete HTML
> page online will get you a better quality of criticism than inserting
> javascript in your email message.
>
> Regards,
> Paul
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>



More information about the Javascript mailing list