0

My code is here: http://jsfiddle.net/spadez/LRFMQ/14/

I tried to add two select fields to each line when hitting the add question button, so the added questions have the same fields as the initial one.

This is the problem bit of the code:

<select>
    <option value="single">Single line reply</option>
    <option value="multi">Paragraph reply</option>
</select>
<select>
    <option value="single">Required</option>
    <option value="multi">Optional</option>
</select>

It doesnt seem to like the way I have added my html form code into the javascript. Do I need to escape it somehow?

Gogutz
  • 2,005
  • 17
  • 19
Jimmy
  • 12,087
  • 28
  • 102
  • 192
  • have you visted http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript – Satpal Apr 25 '14 at 11:43
  • There's no need to make appended or dynamic html look tidy. Just add it as a string, with no indentation (or put a single \ at the end of each line of unterminated text : http://jsfiddle.net/ArchersFiddle/LRFMQ/17/) – Reinstate Monica Cellio Apr 25 '14 at 11:46
  • http://jsfiddle.net/9kGy6/, Just used string concatenation properly – Satpal Apr 25 '14 at 11:48

1 Answers1

0

Use a hidden div for structure and .clone it for adding.

$("div.toClone").clone().removeClass("toClone").insertBefore(InputsWrapper);

FIDDLE

Batu.Khan
  • 3,060
  • 2
  • 19
  • 26