From: MC on

"David Mark" <dmark.cinsoft(a)gmail.com> wrote in message
news:be291d52-360d-464e-9f26-4e8b612e368d(a)a13g2000vbf.googlegroups.com...
> On Feb 9, 1:20 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> David Mark, my favorite javascript guy!
>
> Hey!
>
>>
>> Yes, I am trying to get the user input from checkbox, radio, input, and
>> select.
>
> There are inputs, selects and textareas (checkbox and radio are
> _types_ of inputs).
>
>> It seems the input is retrieved via innerHTML but the other is not.
>>
>
> The results of that proprietary property are implementation
> dependant. You will have to traverse the DOM and use the checked,
> value and selectedIndex properties to determine the states of the form
> controls. It sounds as if the browsers you tested were referencing
> the defaultChecked and defaultSelected properties for radio/checkbox
> inputs and select options, but not the defaultValue property for text
> inputs. That's certainly an incongruous approach.
>
> Also, if you must deal with multi-selects, there is no single property
> to reference (you have to loop through the options and check the
> selected property for each).
>
> And I've got to ask, what is the purpose of this? Seems like a can of
> worms that doesn't need to be opened.
>
> Please don't top-post. It screws up the context of the dicussion (and
> I don't care to restore it).

Purpose: Document a page into an archive (with user input) via ajax. These
pages are basically user forms that are then sent to a document archive
service. Without the user input, archival is useless.


From: David Mark on
On Feb 9, 1:57 pm, "MC" <mica[removethis]@aisus.com> wrote:
> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>
> news:be291d52-360d-464e-9f26-4e8b612e368d(a)a13g2000vbf.googlegroups.com...
>
>
>
> > On Feb 9, 1:20 pm, "MC" <mica[removethis]@aisus.com> wrote:
> >> David Mark, my favorite javascript guy!
>
> > Hey!
>
> >> Yes, I am trying to get the user input from checkbox, radio, input, and
> >> select.
>
> > There are inputs, selects and textareas (checkbox and radio are
> > _types_ of inputs).
>
> >> It seems the input is retrieved via innerHTML but the other is not.
>
> > The results of that proprietary property are implementation
> > dependant. You will have to traverse the DOM and use the checked,
> > value and selectedIndex properties to determine the states of the form
> > controls. It sounds as if the browsers you tested were referencing
> > the defaultChecked and defaultSelected properties for radio/checkbox
> > inputs and select options, but not the defaultValue property for text
> > inputs. That's certainly an incongruous approach.
>
> > Also, if you must deal with multi-selects, there is no single property
> > to reference (you have to loop through the options and check the
> > selected property for each).
>
> > And I've got to ask, what is the purpose of this? Seems like a can of
> > worms that doesn't need to be opened.
>
> > Please don't top-post. It screws up the context of the dicussion (and
> > I don't care to restore it).
>
> Purpose: Document a page into an archive (with user input) via ajax. These
> pages are basically user forms that are then sent to a document archive
> service. Without the user input, archival is useless.

Deja vu. Haven't we had this discussion before?

Personally, I would serialize the data without the markup. ;)
From: MC on

"David Mark" <dmark.cinsoft(a)gmail.com> wrote in message
news:fae9c4d0-11b6-46ec-a448-a202172ff873(a)b18g2000vba.googlegroups.com...
> On Feb 9, 1:57 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>>
>> news:be291d52-360d-464e-9f26-4e8b612e368d(a)a13g2000vbf.googlegroups.com...
>>
>>
>>
>> > On Feb 9, 1:20 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> >> David Mark, my favorite javascript guy!
>>
>> > Hey!
>>
>> >> Yes, I am trying to get the user input from checkbox, radio, input,
>> >> and
>> >> select.
>>
>> > There are inputs, selects and textareas (checkbox and radio are
>> > _types_ of inputs).
>>
>> >> It seems the input is retrieved via innerHTML but the other is not.
>>
>> > The results of that proprietary property are implementation
>> > dependant. You will have to traverse the DOM and use the checked,
>> > value and selectedIndex properties to determine the states of the form
>> > controls. It sounds as if the browsers you tested were referencing
>> > the defaultChecked and defaultSelected properties for radio/checkbox
>> > inputs and select options, but not the defaultValue property for text
>> > inputs. That's certainly an incongruous approach.
>>
>> > Also, if you must deal with multi-selects, there is no single property
>> > to reference (you have to loop through the options and check the
>> > selected property for each).
>>
>> > And I've got to ask, what is the purpose of this? Seems like a can of
>> > worms that doesn't need to be opened.
>>
>> > Please don't top-post. It screws up the context of the dicussion (and
>> > I don't care to restore it).
>>
>> Purpose: Document a page into an archive (with user input) via ajax.
>> These
>> pages are basically user forms that are then sent to a document archive
>> service. Without the user input, archival is useless.
>
> Deja vu. Haven't we had this discussion before?
>
> Personally, I would serialize the data without the markup. ;)

We have and I didn't find an answer. Prior to this, the archival software
was not finished. The archival software is now complete and working like a
champ turning html into beautiful pdf exactly like the html form. So now the
project is going live and I need to resolve this last issue.


From: David Mark on
On Feb 9, 2:14 pm, "MC" <mica[removethis]@aisus.com> wrote:
> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>
> news:fae9c4d0-11b6-46ec-a448-a202172ff873(a)b18g2000vba.googlegroups.com...
>
>
>
> > On Feb 9, 1:57 pm, "MC" <mica[removethis]@aisus.com> wrote:
> >> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>
> >>news:be291d52-360d-464e-9f26-4e8b612e368d(a)a13g2000vbf.googlegroups.com...
>
> >> > On Feb 9, 1:20 pm, "MC" <mica[removethis]@aisus.com> wrote:
> >> >> David Mark, my favorite javascript guy!
>
> >> > Hey!
>
> >> >> Yes, I am trying to get the user input from checkbox, radio, input,
> >> >> and
> >> >> select.
>
> >> > There are inputs, selects and textareas (checkbox and radio are
> >> > _types_ of inputs).
>
> >> >> It seems the input is retrieved via innerHTML but the other is not.
>
> >> > The results of that proprietary property are implementation
> >> > dependant. You will have to traverse the DOM and use the checked,
> >> > value and selectedIndex properties to determine the states of the form
> >> > controls. It sounds as if the browsers you tested were referencing
> >> > the defaultChecked and defaultSelected properties for radio/checkbox
> >> > inputs and select options, but not the defaultValue property for text
> >> > inputs. That's certainly an incongruous approach.
>
> >> > Also, if you must deal with multi-selects, there is no single property
> >> > to reference (you have to loop through the options and check the
> >> > selected property for each).
>
> >> > And I've got to ask, what is the purpose of this? Seems like a can of
> >> > worms that doesn't need to be opened.
>
> >> > Please don't top-post. It screws up the context of the dicussion (and
> >> > I don't care to restore it).
>
> >> Purpose: Document a page into an archive (with user input) via ajax.
> >> These
> >> pages are basically user forms that are then sent to a document archive
> >> service. Without the user input, archival is useless.
>
> > Deja vu. Haven't we had this discussion before?
>
> > Personally, I would serialize the data without the markup. ;)
>
> We have and I didn't find an answer. Prior to this, the archival software
> was not finished. The archival software is now complete and working like a
> champ turning html into beautiful pdf exactly like the html form. So now the
> project is going live and I need to resolve this last issue.

You will have to traverse the form and build the HTML string yourself
as innerHTML is not an appropriate format to store (varies from one
browser to the next). Have you tried to do that? If you only need
form controls, it is fairly trivial. First define what sort of form
controls will be involved (e.g. what about textareas?)

Start with something like this:-

function serializeFormHtml(name) {
var el = document.forms[name];
var control, controls = el.elements;
var result = [];

for (var i = controls.length; i--;) {
control = controls[i];
switch (control.tagName.toLowerCase()) {
case 'input':
...
break;
case 'select':
...
break;
case 'textarea':
...
break;
}
}

return result.join('');
}

You will have to fill in the blanks as only you know the context of
your application. For example, other than name and value; what, if
any, attributes should be included? Will there be multi-selects, do
you care about disabled controls, etc.?
From: MC on

"David Mark" <dmark.cinsoft(a)gmail.com> wrote in message
news:685a01f4-502a-4829-9f5f-04791fbef3a9(a)f15g2000yqe.googlegroups.com...
> On Feb 9, 2:14 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>>
>> news:fae9c4d0-11b6-46ec-a448-a202172ff873(a)b18g2000vba.googlegroups.com...
>>
>>
>>
>> > On Feb 9, 1:57 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> >> "David Mark" <dmark.cins...(a)gmail.com> wrote in message
>>
>> >>news:be291d52-360d-464e-9f26-4e8b612e368d(a)a13g2000vbf.googlegroups.com...
>>
>> >> > On Feb 9, 1:20 pm, "MC" <mica[removethis]@aisus.com> wrote:
>> >> >> David Mark, my favorite javascript guy!
>>
>> >> > Hey!
>>
>> >> >> Yes, I am trying to get the user input from checkbox, radio, input,
>> >> >> and
>> >> >> select.
>>
>> >> > There are inputs, selects and textareas (checkbox and radio are
>> >> > _types_ of inputs).
>>
>> >> >> It seems the input is retrieved via innerHTML but the other is not.
>>
>> >> > The results of that proprietary property are implementation
>> >> > dependant. You will have to traverse the DOM and use the checked,
>> >> > value and selectedIndex properties to determine the states of the
>> >> > form
>> >> > controls. It sounds as if the browsers you tested were referencing
>> >> > the defaultChecked and defaultSelected properties for radio/checkbox
>> >> > inputs and select options, but not the defaultValue property for
>> >> > text
>> >> > inputs. That's certainly an incongruous approach.
>>
>> >> > Also, if you must deal with multi-selects, there is no single
>> >> > property
>> >> > to reference (you have to loop through the options and check the
>> >> > selected property for each).
>>
>> >> > And I've got to ask, what is the purpose of this? Seems like a can
>> >> > of
>> >> > worms that doesn't need to be opened.
>>
>> >> > Please don't top-post. It screws up the context of the dicussion
>> >> > (and
>> >> > I don't care to restore it).
>>
>> >> Purpose: Document a page into an archive (with user input) via ajax.
>> >> These
>> >> pages are basically user forms that are then sent to a document
>> >> archive
>> >> service. Without the user input, archival is useless.
>>
>> > Deja vu. Haven't we had this discussion before?
>>
>> > Personally, I would serialize the data without the markup. ;)
>>
>> We have and I didn't find an answer. Prior to this, the archival software
>> was not finished. The archival software is now complete and working like
>> a
>> champ turning html into beautiful pdf exactly like the html form. So now
>> the
>> project is going live and I need to resolve this last issue.
>
> You will have to traverse the form and build the HTML string yourself
> as innerHTML is not an appropriate format to store (varies from one
> browser to the next). Have you tried to do that? If you only need
> form controls, it is fairly trivial. First define what sort of form
> controls will be involved (e.g. what about textareas?)
>
> Start with something like this:-
>
> function serializeFormHtml(name) {
> var el = document.forms[name];
> var control, controls = el.elements;
> var result = [];
>
> for (var i = controls.length; i--;) {
> control = controls[i];
> switch (control.tagName.toLowerCase()) {
> case 'input':
> ...
> break;
> case 'select':
> ...
> break;
> case 'textarea':
> ...
> break;
> }
> }
>
> return result.join('');
> }
>
> You will have to fill in the blanks as only you know the context of
> your application. For example, other than name and value; what, if
> any, attributes should be included? Will there be multi-selects, do
> you care about disabled controls, etc.?

All of those controls will be dealt with. We are not storing html but
converting html into a pdf representation and it is pretty exact. Its
actually really cool, as users go about their day, their work is
automatically e-archived via ajax, saving them a huge amount of time/money
printing and filing.

What about this? It seems to work.

while (e = oForm.elements[i++]) {
if (e.type == 'checkbox') {
if (e.checked == true) {
e.defaultChecked = true;
} else {
e.defaultChecked = false;
}
}
if (e.type == 'radio') {
var x = e.name;
if (e.checked == true) {
e.defaultChecked = true;
} else {
e.defaultChecked = false;
}
}
}