A
A
Alexey2015-09-22 23:52:51
PHP
Alexey, 2015-09-22 23:52:51

Where to store empty forms to include in DOM?

I have a form with something like this:

<div class="grid_12">
        	<label>1</label>
        	<div class="grid_4">
            	<div class="upload_image">
                	<input type="file" name="fileUpload" id="fileUpload" class="fileUpload" />
                	<div class="upimtx">
                        <p><i class="icon-plus"></i></p>
                        <p>Картинка</p>
                    </div>
                </div>
            </div>
            <div class="grid_8 pl_10">
            	<textarea name="text[]"></textarea>
            </div>
        </div>


Below this block is a button that, when clicked, should add another such form. When do you generate this code? Do you insert it into js when generating the page, or do you clone an existing one by clearing the elements if they are filled, or are there any other methods?
I used to send it from the server when generating the page and put it in js, but is this correct?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Inchin ☢, 2015-09-23
@In4in

Use templates .
It is not proper to call a form what is not a form.

A
Alexander Varakosov, 2015-09-23
@thelongrunsmoke

If the form contains critical data, then it is better to append it from js, and exclude it from the markup. So that when JavaScript is turned off, it is not displayed. And if the form is rarely used, then it can also be requested via ajax.

Z
Zakharov Alexander, 2015-09-23
@AlexZaharow

jQuery append ok? api.jquery.com/append

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question