jlizarraga
03-12-2009, 11:49 PM
Hi all,
Apparently I'm going about creating a form with JS the wrong way, because I get strange results in both FF3 and IE6. I'm thinking it's probably something simple that I'm overlooking, but this issue has some back story so stick around if you're a trooper. :)
Using Niceforms (http://www.emblematiq.com/projects/niceforms/), I have created a nifty dynamic form (http://www.autofusion.com/development/josh/demos/service/index-dd.html) for scheduling a service appointment at a car dealership. The current service form that we use does not have areas to tell the dealer exactly what type of service your car needs, and so similarly our CGI script that processes service forms is not prepared to handle these new fields. Additionally, the new service form makes use of checkbox groups, and the CGI is not prepared to handle them.
In case you missed it: http://www.autofusion.com/development/josh/demos/service/index-dd.html
Because of these limitations of the CGI script, my solution was to simply create a form element from JS that is compatible with the CGI, insert text inputs for the checkboxes (example: <input type="text" name="someGroup" value="checked1, checked2, etc"), and insert any new fields into the comments section. Then the JS-created form is appended to document.body (Firefox and IE won't submit a form that only exists in the DOM, Safari/Opera/Chrome all will) and submitted via form.submit() instead of the one that was actually filled out. Note that I'm using DOM methods and no innerHTML to achieve this.
Sounds simple enough, but the JS-created form has some bizarre problems. In IE6, only <input> and <textarea> make it through, and ALL attributes are lost. Similarly, in FF3, only <input> and <textarea> make it to the HTML when the form is appended, and they loose their "value" attribute, except for hidden inputs which for some reason are the only form control not adversely affected. Just to make it weirder and more frustrating, Firebug reports that the JS-created form does indeed have all of the form controls (with their correct attributes/properties such as the missing "value"), but the HTML does not reflect this.
I'm stumped! :confused: I know rewriting the CGI is probably the best bet, but I have to work with what I've been given.
Any help greatly appreciated! Thanks for reading this far, at least.
The JS file in question is:
http://www.autofusion.com/development/josh/demos/service/service-dd.js
Lines 648 to 755 - It's the YAHOO.ssf.submitForm() function.
EDIT: Sorry, the only controls coming through being <input> and <textarea> is correct. I forgot that I was converting <select> elements to text inputs along with the checkboxes.
Apparently I'm going about creating a form with JS the wrong way, because I get strange results in both FF3 and IE6. I'm thinking it's probably something simple that I'm overlooking, but this issue has some back story so stick around if you're a trooper. :)
Using Niceforms (http://www.emblematiq.com/projects/niceforms/), I have created a nifty dynamic form (http://www.autofusion.com/development/josh/demos/service/index-dd.html) for scheduling a service appointment at a car dealership. The current service form that we use does not have areas to tell the dealer exactly what type of service your car needs, and so similarly our CGI script that processes service forms is not prepared to handle these new fields. Additionally, the new service form makes use of checkbox groups, and the CGI is not prepared to handle them.
In case you missed it: http://www.autofusion.com/development/josh/demos/service/index-dd.html
Because of these limitations of the CGI script, my solution was to simply create a form element from JS that is compatible with the CGI, insert text inputs for the checkboxes (example: <input type="text" name="someGroup" value="checked1, checked2, etc"), and insert any new fields into the comments section. Then the JS-created form is appended to document.body (Firefox and IE won't submit a form that only exists in the DOM, Safari/Opera/Chrome all will) and submitted via form.submit() instead of the one that was actually filled out. Note that I'm using DOM methods and no innerHTML to achieve this.
Sounds simple enough, but the JS-created form has some bizarre problems. In IE6, only <input> and <textarea> make it through, and ALL attributes are lost. Similarly, in FF3, only <input> and <textarea> make it to the HTML when the form is appended, and they loose their "value" attribute, except for hidden inputs which for some reason are the only form control not adversely affected. Just to make it weirder and more frustrating, Firebug reports that the JS-created form does indeed have all of the form controls (with their correct attributes/properties such as the missing "value"), but the HTML does not reflect this.
I'm stumped! :confused: I know rewriting the CGI is probably the best bet, but I have to work with what I've been given.
Any help greatly appreciated! Thanks for reading this far, at least.
The JS file in question is:
http://www.autofusion.com/development/josh/demos/service/service-dd.js
Lines 648 to 755 - It's the YAHOO.ssf.submitForm() function.
EDIT: Sorry, the only controls coming through being <input> and <textarea> is correct. I forgot that I was converting <select> elements to text inputs along with the checkboxes.