Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35104
| From | JR <jr@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Serialise form with input of type image |
| Date | 2018-05-23 16:42 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <pe4g7g$j24$1@gioia.aioe.org> (permalink) |
| References | <LfqdneZ61dqoiGDHnZ2dnUU7-IvNnZ2d@westnet.com.au> |
Andrew Poulos wrote:
> I have a form and some of the form elements are inputs of type image.
> For example
>
> <input type="image" src="...blah" style="..blah">
>
> When I pass the form to
>
> function serialiseForm(frm) {
> return [].map.call(frm.elements, function(el) {
> return {
> "type": el.type,
> ...
> };
> });
> }
>
> It picks up every input (text, button, checkbox, number, radio...)
> except those of type image. Why does it seem to ignore inputs of type
> image, and how do I get it to also include them?
>
As Christoph M. Becker has already posted, input of type="image" is not
included in HTMLFormElement.elements [1]. So, you'll have to add these
inputs in your code. For instance:
function serialiseForm(frm) {
return [].map.call([...frm.elements,
...frm.querySelectorAll("input[type=image]")],
el => ({type:el.type /*, ...*/}));
}
[1]
<https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements>
Cheers,
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Serialise form with input of type image Andrew Poulos <ap_prog@hotmail.com> - 2018-05-17 15:37 +1000
Re: Serialise form with input of type image Andrew Poulos <ap_prog@hotmail.com> - 2018-05-17 18:56 +1000
Re: Serialise form with input of type image "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-17 13:24 +0200
Re: Serialise form with input of type image Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-05-22 15:55 +0200
Re: Serialise form with input of type image Andrew Poulos <ap_prog@hotmail.com> - 2018-05-23 10:17 +1000
Re: Serialise form with input of type image JR <jr@yahoo.com> - 2018-05-23 16:42 -0300
Re: Serialise form with input of type image Andrew Poulos <ap_prog@hotmail.com> - 2018-05-24 11:21 +1000
Re: Serialise form with input of type image Joao Rodrigues <jr@yahoo.com> - 2018-05-24 00:41 -0300
Re: Serialise form with input of type image Andrew Poulos <ap_prog@hotmail.com> - 2018-05-24 18:17 +1000
csiph-web