There are two instances of Javascript failing through Safari. It's only safari, I've tested on multiple machines with different versions.
I have a large form, at one point in the form, they submit via AJAX (don't worry it's all validated and safe to send). I pick the information up using this method:
var vcompany = document.forms['registerForm']['vcompan开发者_如何学Pythony'].value;
This doesn't seem to work. Also, in another instance I am picking information up from a form and calculating based on that information, then outputting it as a total price. This also does not seem to work:
var dates_A = document.forms['registerForm']['childADates[]']; //from a checkbox group
Does anybody know of any issues? I'm not getting an error, the commands just aren't firing...
I suppose this is one of the key moments of stupidity in my life... I had a variable named class which all browsers accepted but Safari would not, it is a reserved word. The moment of stupidity: not checking the error log.
Any particular reason you are getting references to the form elements via document.forms?
You should get better cross browser results by either document.getElementById() or document.getElementsByTagName().
//if you have the same id's as the input's "name" attribute
var vcompany = document.getElementById('vcompany').value;//text input
var dates_A = document.getElementById('childADates[]').checked;//checkbox
Give that a shot.
精彩评论