I''m trying to send to my application the coords x,y on an "input type image" in a html form, but x,y variables are not present in the POST_DATA (are not submitted). Any other field (hidden inputs) are being sent when I click on the image input form field. I use rails 1.0 and prototype 1.4, browsers Seamonkey 2.0, Firefox 1.x and Konqueror, Linux, and I''m just a newbie in ror. Html code generated by rails: <form action="/pixel/set" method="post" onsubmit=" new Ajax.Updater(''coords'', ''/pixel/set'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> <div><input name="matrix" type="image" src="/images/all.png" /></div> </form> In POST_DATA I have ''''. Tried it without ajax: <form action="/pixel/set" method="post"> <div id="pixels"> <div><input name="matrix" type="image" src="/images/all.png" /></div> </form> In POST_DATA i have matrix.x=572&matrix.y=443. Hints, anyone? The code in the rhtml template is: <%= form_remote_tag(:update => "coords", :url => { :action => "set" }) %> <div id="pixels"> <div><input name="matrix" type="image" src="/images/all.png" /></div> <%= end_form_tag %> -- They say money can''t buy happiness? Look at the smile on my face... ear to ear, baby!
My guess is that Form.serialize (in prototype.js) ignores <input type="image"> You could modify Form.Element.Serializers (input) and add the desired behaviour for type "image" Bogdan On 3/13/06, Constantin Gavrilescu <costi@net.usr.ro> wrote:> > I''m trying to send to my application the coords x,y on an "input type > image" in a html form, but x,y variables are not present in the > POST_DATA (are not submitted). Any other field (hidden inputs) are being > sent when I click on the image input form field. > > I use rails 1.0 and prototype 1.4, browsers Seamonkey > 2.0, Firefox 1.x and Konqueror, Linux, and I''m just a newbie in ror. > > Html code generated by rails: > <form action="/pixel/set" method="post" onsubmit=" > new Ajax.Updater(''coords'', ''/pixel/set'', {asynchronous:true, > evalScripts:true, parameters:Form.serialize(this)}); return false;"> > <div><input name="matrix" type="image" src="/images/all.png" /></div> > </form> > > In POST_DATA I have ''''. > > > > Tried it without ajax: > <form action="/pixel/set" method="post"> > <div id="pixels"> > <div><input name="matrix" type="image" src="/images/all.png" > /></div> > </form> > > In POST_DATA i have matrix.x=572&matrix.y=443. > > > Hints, anyone? The code in the rhtml template is: > > <%= form_remote_tag(:update => "coords", > :url => { :action => "set" }) %> > <div id="pixels"> > <div><input name="matrix" type="image" src="/images/all.png" > /></div> > <%= end_form_tag %> > > > -- > They say money can''t buy happiness? Look at the smile on my face... ear > to ear, baby! > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/92813cd6/attachment.html
Cam pe la 03/13/2006 04:00 PM, Bogdan Ionescu scrise:> My guess is that Form.serialize (in prototype.js) ignores <input > type="image"> > You could modify Form.Element.Serializers (input) and add the desired > behaviour for type "image"Your guesss is be right. But after some reading, i found out that x,y coordinates of the click are not available in the forms objects, so can''t use <input type="image">. I''ll try something else. Form.Element.Serializers = { input: function(element) { switch (element.type.toLowerCase()) { case ''submit'': case ''hidden'': case ''password'': case ''text'': return Form.Element.Serializers.textarea(element); case ''checkbox'': case ''radio'': return Form.Element.Serializers.inputSelector(element); } return false; }, -- They say money can''t buy happiness? Look at the smile on my face... ear to ear, baby!