Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Gurus...need assistance with IE 6 and IE 7 browser

Status
Not open for further replies.

2levelsabove

IS-IT--Management
Feb 25, 2008
5
0
0
US
IE 6 and IE 7 are throwing errors at me. The JS error I get is
'elements[...].value' is null or Not an object

Code:0

What could it be ? Please help me


Code:
var bform = document.forms['billing'];

var postStr = window.location.search.substring(1);

 for (var m in bform.elements) {
 if ((bform.elements[m].value != null) && (bform.elements[m].value != null))
  {postStr += "&" + bform.elements[m].name + "=" + escape(bform.elements[m].value);
                                                                     
             
                                }
     
                                req.send(postStr);
 
Does
Code:
var m in bform.elements
provide you with an element object, or the index of an existing element?

Lee
 
Well, then test it to make sure. If it's the element object, you have an obvious error using
Code:
bform.elements[m]

You write the code, you test it to see what it's producing.

Lee
 
DO you have any JS frameworks in play that you've not mentioned (such as Prototype, JQuery, etc)? Some of these modify the DOM so that the "in" syntax you're using gives you much more that you think.

If so, use a regular "for" loop instead.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yes thankyou so much for asking

The for had some issues involved


I did:
///////////////////////////////////////////////////
var postStr = window.location.search.substring(1);
for(i=0; i<document.forms["billing"].elements.length; i++)
{
//alert("The field name is: " + document.forms["billing"].elements.name + " and it’s value is: " + document.forms["billing"].elements.value + ".<br />");

postStr += "&" + document.forms["billing"].elements.name + "=" + escape(document.forms["billing"].elements.value);
}
///////////////////////////////////////////////////


and it seemed to work fine.


Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top