Dynamically creating textbox and a button
<p>In my application I am using the following lines of code to displaying textbox and a button dynamically when the user select <strong>NS</strong> option in the select option to enter the comments. There are more than 50 select option are there.</p>

<pre><code>&lt;select name="fieldname"  id="crm_Communications" onchange="comment_add(this)"&gt;
&lt;option value="S" selected="selected"&gt;S&lt;/option&gt;
&lt;option value="NS"&gt;NS&lt;/option&gt;
    &lt;/select&gt;
// code to create textbox and a button
function comment_add(rid)
{
    var sel = rid.id;
    var val = $('#'+sel).val();

    if(val == 'NS')
    {

        var element = document.createElement("input");
        element.setAttribute("type", 'text');
        element.setAttribute("value", 'comment');
        element.setAttribute("class", 'TxtField');
         element.setAttribute("name", 'data[RouteComment]['+sel+']');
          element.setAttribute("id", 'dataRouteComment'+sel+'');
          var ele_id = 'dataRouteComment'+sel+'';

          var ok = document.createElement("input");
             ok.setAttribute("type", 'button');
            ok.setAttribute("value", 'OK');
             ok.setAttribute("id", 'id'+sel);
            ok.setAttribute("onclick", "get_content('"+ele_id+"')");

        $('#'+sel).after(element);
        $('#dataRouteComment'+sel).after(ok);
    }
}

// here i am displaying the the textfield value
function get_content(id)
{
    var pos = id.indexOf('_'); // id s like id_fieldname

var field_name = id.substring(pos+1);

    var show = field_name+':'+$('#'+id).val()+', ';
    $('#textarea').append(show);
}   
</code></pre>

<p>the problem is<br>
1. when i select <strong>NS</strong> more than once for the same select its opening those many textboxes and a button. i need it be only once.<br>
2. When i edit the text box content and saving but its saves as many times as i edit. i am new to jquery so, please someone help  </p>
