0

I have created a dynamic form using JavaScript and want to handle this dynamically generated form using nodejs. Here is my JavaScript snippet for dynamic form:

var s=0;
    function add_slide(){
        s++;
        var mydiv = document.getElementById('my_div');
        var div = document.createElement('div');
        div.className ='col-md-4';
        var indiv = document.createElement('div');
        indiv.class='field_group html1';
        var label = document.createElement('label');
        label.innerHTML="Slide " + s + "Title :";
        var label1 = document.createElement('label');
            label1.innerHTML="Slide " + s + " Read More Link :";
        var title = document.createElement('input');
            title.type='text';
            title.name='title'+ s;
            title.className='form-control';
        var rm_url = document.createElement('input');
            rm_url.type='url';
            rm_url.className='form-control';
            rm_url.name='slide'+s+'_url';
        var span1 = document.createElement('span');
        span1.className='help-block';
        span1.innerHTML='Put title for Slide '+ s+'.';
        var span2 = document.createElement('span');
        span2.className='help-block';
        span2.innerHTML='Put Button link for Slide '+ s+'.';
        div.appendChild(indiv);
        indiv.appendChild(label);
        indiv.appendChild(title);
        indiv.appendChild(span1);
        indiv.appendChild(label1);
        indiv.appendChild(rm_url);
        indiv.appendChild(span2);
        mydiv.appendChild(div);
    }
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
  • What have you tried so far? Show us the code you have a problem with. There are tons of examples on internet on how to do this. Try google first. – Molda Apr 16 '16 at 07:57
  • i have google it a lot but doesn't find a resource to learn dynamic form handling using node.Can you provide me some resources please? – Abdul Rehman Apr 16 '16 at 10:12
  • Ok do you use any framework like express, or anything else? – Molda Apr 16 '16 at 19:11
  • yah! i'm using express. – Abdul Rehman Apr 17 '16 at 02:58
  • So you are using express library make sure you have installed body-parser library to parse the request. So you could make simple XHR request and sending the form data to server or just make form request to some page. For nested data parsing you could take a look at this example http://stackoverflow.com/questions/18175335/how-does-one-parse-nested-elements-using-express-bodyparser-node-formidable. – Risto Novik Apr 18 '16 at 17:16

0 Answers0