Google Chrome form will not change

How do I get Google Chrome (9.0.597.98 on Windows 7 64-bit) to run the exchange form? If you play with the following example, nothing calms down. It works fine in Firefox 3.6.13.

<form onchange="console.info('form changed')"> <select> <option>uno</option> <option>dos</option> </select> <input type="radio" name="videoDevice" value="tres" checked="checked" /> <input type="radio" name="videoDevice" value="cuatro" checked="checked" /> </form> 
+8
javascript html google-chrome
source share
3 answers

Binding change event via JS works fine:

HTML

 <form id="test"> <select> <option>uno</option> <option>dos</option> </select> <input type="radio" name="videoDevice" value="tres" checked="checked" /> <input type="radio" name="videoDevice" value="cuatro" checked="checked" /> </form> 

Js

 document.getElementById('test').addEventListener('change', function() { alert('change fired'); }, false); 
+11
source share

Basically, a form has only the following two events: onreset, onsubmit. You can do a workaround:

 window.onload=(function () { var Form= { w3c: !!window.addEventListener, addEvent: function (form,type,listener) { var inputs=form.elements; for (var i=0,l=inputs.length; i<l; ++i) { var input=inputs[i]; if (this.w3c) { input.addEventListener(type,listener,false); } else { input.attachEvent("on"+type,listener); } } }, fixEvents: function (form) { var eventPattern=/^on(\w+)$/; var attribute; for (var i=0,l=form.attributes.length; i<l; ++i) { var attribute=form.attributes.item(i); var name=attribute.name; var value=attribute.value; if (eventPattern.test(name) && !form[name]) { var type=eventPattern.exec(name)[1]; var listener=new Function(value); this.addEvent(form,type,listener); } } } }; return function () { var forms=document.getElementsByTagName("form"); for (var i=0,l=forms.length; i<l; ++i) { Form.fixEvents(forms[i]); } }; })(); 
+1
source share
  var button = document.form.adet; if (button.addEventListener) { // all browsers except IE before version 9 button.addEventListener ("change", function () { alert('1'); }, false); } else { if (button.attachEvent) { // IE before version 9 button.attachEvent ("onchange", function () { alert('2'); }); } } 
+1
source share

All Articles