Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Further question on cloneNode

41 views
Skip to first unread message

justaguy

unread,
Aug 14, 2017, 3:56:49 PM8/14/17
to
When a clone source object has multiple input fields (see the following URL).

if they are of type TEXT and with value, I want the clone target object to have the blank TEXT fields instead (no problem)
and if they are of type checkbox, I'd like them unchecked by default for all the checkbox fields in the target object (cloned object).

Additional note:
Each Checkbox field is immediately followed by an input Text field and the Rule is if the checkbox is checked then this input Text field must have value.

My first attempt was to set all the checkbox fields in the clone target object to false. Result: all the checkbox fields in the clone target object appears not checked, however, it's misleading because the form is submitted checkbox fields carry the same property of its source (before cloning), for instance, when D1 is cloned with D3 checked, the new D1 (cloned D1) has D3 unchecked, however, D3 in the cloned D1 is marked as required.

My second attempt was to first set the checkbox fields in the source object to false right before cloning and then turn the checkbox fields to true if they are true in the first place. It won't work neither. I guess because of object property inheritance (so, it turns the checkbox fields in the clone target object as well).

Thoughts?

Thanks.

http://54.80.71.115/dev/D1.html

Cezary Tomczyk

unread,
Aug 15, 2017, 2:23:34 AM8/15/17
to
On 14/08/2017 21:56, justaguy wrote:
> When a clone source object has multiple input fields (see the following URL).
[...]
Regarding cloneNode it's worth to read notes as the cloneNode method
doesn't clone node in a way it's expected:

https://developer.mozilla.org/en/docs/Web/API/Node/cloneNode#Notes

--
Cezary Tomczyk
http://www.ctomczyk.pl/

JJ

unread,
Aug 15, 2017, 7:35:01 AM8/15/17
to
My suggestion is to clone the node when the page has finished loading. i.e.
when the checkboxes are still unchecked and the text inputs are still
blanks. Save the cloned node into a variable as the templace node and don't
place it into the document.

When you need to clone the node, clone the template node then place the
newly cloned node into document.

justaguy

unread,
Aug 16, 2017, 5:01:38 PM8/16/17
to
Thanks all.

It seem another method is to have an identical DIV with a different ID and not to display it, then it would appear to be cloning the original one. However, it creates some hassle for the FORM processing because it would an empty array to all the affected input elements.

Personally I'd stay with the minor inconvenience of having to uncheck the cloned checkbox fields within a group vs. faking a DIV (the new method mentioned here) and making the FORM processing less efficient and the possibility of array messing-up.


jonas.t...@gmail.com

unread,
Aug 18, 2017, 9:23:27 AM8/18/17
to
It will be alot easier when we do communicate, if we do it in the same thread lowIQ people who think they are smart is just annoying.

I maybe sloppy but i still have my 178 IQ so i removed the cloned <div class="dropdown"> so you anal pricks can move on with your life, you see i did just copy paste from another project where i did same mistake.

So any chance you could tell me if there is any chance i will be able to open the savedialog from javascript?

Sorry about the anal prick remark but i felt it was justified.

http://anybase.co.nf/Filehandle/readwrite.html

Flng Fck

unread,
Aug 18, 2017, 11:03:45 AM8/18/17
to
Il 18/08/2017 15:23, jonas.t...@gmail.com ha scritto:
> So any chance you could tell me if there is any chance i will be able to open the savedialog from javascript?
>
> Sorry about the anal prick remark but i felt it was justified.
>
> http://anybase.co.nf/Filehandle/readwrite.html


It appears as expected, on Chrome 60.0.3112.101 (Build ufficiale) (64
bit) on WIndows 10, and saves the text correctly to a txt file

jonas.t...@gmail.com

unread,
Aug 18, 2017, 11:26:39 AM8/18/17
to
Yes i know "but for the last time" is there a way to open windows savedialog so i can get rid of the fucking input field in the menu?

Either there is, or not, do anyone know, it is a simple "yes you can" point to example or "no you can't" question?

JJ

unread,
Aug 21, 2017, 10:41:15 AM8/21/17
to
On Fri, 18 Aug 2017 08:26:28 -0700 (PDT), jonas.t...@gmail.com wrote:
> Yes i know "but for the last time" is there a way to open windows
> savedialog so i can get rid of the fucking input field in the menu?
>
> Either there is, or not, do anyone know, it is a simple "yes you can"
> point to example or "no you can't" question?

Yes, you can.

Store the original file name which was previously chosen from the open-file
dialog into the `download` attribute of an `A` element (instead of an
`INPUT` element). Call the `click()` method of that `A` element to display
the save-file dialog (and download the URL pointed by that `A` element). The
`A` element must be placed into the document in order to work. Hide the `A`
element if necessary.

<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download>

Thomas 'PointedEars' Lahn

unread,
Aug 22, 2017, 9:39:17 PM8/22/17
to
JJ wrote:

> Store the original file name which was previously chosen from the
> open-file dialog into the `download` attribute of an `A` element (instead
> of an `INPUT` element). Call the `click()` method of that `A` element to
> display the save-file dialog (and download the URL pointed by that `A`
> element). The `A` element must be placed into the document in order to
> work.

In Chromium, this triggers a confirmation dialog of the form

| [x]
| http://example/ wants to:
|
| [v] Download multiple files
|
| [ Block ] [ Allow ]

Since the `download` attribute is an HTML5 feature, it might be better to
trigger a server-side script that suggests the download instead.

--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
0 new messages