My girlfriend wrote an electronic form with some Java script code.
However some buttons don’t work on IE (like the "submit and “default values” battens).
Could someone please have a quick view and maybe tell me what should be changed?
It’s just that IE6 and 7 have very large differences between “no doctype” and a doctype (their Quirks Mode is extremely noticeable because in Quirks Mode they render pages the same way IE5 did!). Firefox on the other hand might not look hugely different between quirks, almost standard and standard.
Also, IE6 is sensitive to where the doctype is. It should be char 1, line1 of the HTML page. Comments, whitespace, even those xml prologues some people put before the <html> tag will make IE6 ignore the doctype and go into quirks. IE7 has the same problem but knows to ignore the xml line. Not that there should be an xml prologue… that’s only for real XHTML/XML.
Your page may look vastly different after adding the doctype. However, with a doctype, you can validate your HTML at the W3C validator, and having good HTML does matter to Javascript (the DOM, the structure of the HTML document, is what Javascript uses).
I think Paul (pmw57) is closer to your actual problem in your JS, I’m just pointing out that you have other issues going on as well.
HTML4.01 Strict is the most standard you can get. However, that doesn’t mean that the web browsers have to follow them.
if you want some way to guarantee that everything will work problem free on IE6 through to IE8, we can only come close to that with practice and experience.
Might be unrelated question, but does the actual page have a doctype? I’m unsure what IE6 and 7 do in Quirks Mode regarding JS, but if the page really does start with <html> (maybe you were making the code less verbose for us though), they are certainly in Quirks Mode.
Also, it wouldn’t hurt to have a good HTML form instead of what you’ve got. Doesn’t change the Javascript issue either way, but no reason to spew out forms like that. No blockquotes, tables, or non-form tags like the headers inside the form… add labels to your inputs, with for attributes, escaping your &'s etc.
What’s the difference between the reset button and the default values button? If you start your boxes with default values in the first place (in the HTML), reset will display those.
You check to see if stuff ==false… if someone manually types in a 0, that’s not false… is that okay?
You check to see if one of the two radio buttons has been selected… however, you will never know what user agent automatically chooses one or not, as the HTML specs say whenever you have a group of radio buttons, one must be checked=“checked” at the start anyway. So, not choosing a radio button should never be an option. One should be checked by default anyway.
I’m still new in JS but I didn’t see anything that normally trips up IE in there… why not run your JS through JSLint.com? You can also check for anything like a syntax error using the Javascript error consoles in various browsers (they’ll tell you if you’re missing or have an extra } for example).