title: Setting value to a input field using Jquery val not working.I have commented out code setting value in edit() function
body: <p>/* Setting value to a input field using Jquery val not working.I have commented out code setting value in edit() function.if I try to set value the table data itself not displayed.I wanted to edit the data of a perticular row.*/</p>
  
  <p>Fiddle <strong><a href="http://jsfiddle.net/z9QdK/5/" rel="nofollow noreferrer">here</a></strong> </p>
  
  <pre><code>  &lt;style type="text/css"&gt;
            table,tr,td,th{border:1px solid green;border-collapse:collapse;}
  
                th{background-color:#A7C942;color:white;}
  
                tr:nth-child(2n){background-color:#EAF2D3;}
  
                .controls{ width:200px;padding:15px;border:1px solid gray;height:400px; margin:10px;}
            .controls label{float:left;width:100%;}
  
                .controls input,controls button{float:left;width:100%; margin-bottom:10px;}
            .red{background-color:red;}
        &lt;/style&gt;
  </code></pre>
  
  <p>Scripts are as :</p>
  
  <pre><code> &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript"&gt;
           data=[{id:0,firstName:"Mahesh",lastName:"Hegde",city:"Sirsi",state:"Karnataka",pin:581315},
           {id:1,firstName:"Rajesh",lastName:"Hegde",city:"Kumta",state:"Karnataka",pin:581311},
           {id:2,firstName:"Karthhik",lastName:"bhat",city:"Ankola",state:"Karnataka",pin:581316},
           {id:3,firstName:"Mahantesh",lastName:"naik",city:"Honnavar",state:"Karnataka",pin:581317}];
  
              $(document).ready(function(){
                  displayRecords(data);
              });
          function displayRecords(data){
              for(i=0;i&lt;data.length;i++){
              var html='&lt;tr id="'+data[i].id+'"&gt;&lt;td&gt;'+data[i].firstName+'&lt;/td&gt;&lt;td&gt;'+data[i].lastName+'&lt;/td&gt;&lt;td&gt;'+data[i].city+'&lt;/td&gt;&lt;td&gt;'+data[i].state+'&lt;/td&gt;&lt;td&gt;'+data[i].pin+'&lt;/td&gt;&lt;td&gt;&lt;a href="#" onclick="edit('+data[i].id+')"&gt;Edit&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="#" onclick="deleteRecord('+data[i].id+')"&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';
              $("#jsondata tbody:last").append(html);
              }
          }
          function deleteRecord(id){
          $("#"+id).remove();
          }
          function addRrecord(){
          var totalRecords=data.length;
                  //var objRecord={taskId:recordsCount,description:'Task-1_' +recordsCount,assignedTo:"Ravi_"+recordsCount,dueDate:'12/08/2012_'+recordsCount};
                  var newRecord={
                          id:totalRecords,
                          firstName:$("#firstName").val(),
                          lastName:$("#lastName").val(), 
                          city:$("#city").val(),
                          state:$("#state").val(),
                          pin:$("#pin").val()
                          };
  
                  if($("#firstName").val() !=='' &amp;&amp;$("#lastName").val()!=='' &amp;&amp; $("#city").val()!==''&amp;&amp; $("#state").val()!==''&amp;&amp; $("#pin").val()!=='')
                  {
                      data.push(newRecord);
                      //displayRecords(data);
                      var html='&lt;tr id="'+newRecord.id+'"&gt;&lt;td&gt;'+newRecord.firstName+'&lt;/td&gt;&lt;td&gt;'+newRecord.lastName+'&lt;/td&gt;&lt;td&gt;'+newRecord.city+'&lt;/td&gt;&lt;td&gt;'+newRecord.state+'&lt;/td&gt;&lt;td&gt;'+newRecord.pin+'&lt;/td&gt;&lt;td&gt;&lt;a href="#" onclick="edit('+newRecord.id+')"&gt;Edit&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="#" onclick="deleteRecord('+newRecord.id+')"&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';
                      $("#jsondata tbody:last").append(html);
                      //$("#firstName").val()=='';$("#lastName").val()=='';$("#city").val()==''; $("#state").val()==''; $("#pin").val()=='');
                  }
                  else
                  {
                      alert("Please fill all the fields");
                  }
          }
          function edit(id){
                          /*$("#firstName").val(data[id].firstName);
                          $("#lastName").val(data[id]lastName);
                          $("#city").val(data[id]city);
                          $("#state").val(data[id]state);
                          $("#pin").val(data[id]pin);
                          };*/
          }
  
         &lt;/script&gt;
  </code></pre>
  
  <p>HTML: </p>
  
  <pre><code>            &lt;table id="jsondata"&gt;
                   &lt;tr&gt;&lt;th&gt;First name&lt;/th&gt;
                       &lt;th&gt;Last name&lt;/th&gt;
                       &lt;th&gt;City&lt;/th&gt;
                       &lt;th&gt;State&lt;/th&gt;
                       &lt;th&gt;PIN&lt;/th&gt;
  
                       &lt;th colspan=2&gt;Action&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;tbody&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;     
              &lt;div class="controls"&gt;
                  &lt;label for="firstName"&gt;First Name&lt;/label&gt;&lt;input type="text" id="firstName"&gt;
                  &lt;label for="lastName"&gt;Last Name&lt;/label&gt;&lt;input type="text" id="lastName"&gt;
                  &lt;label for="city"&gt;City&lt;/label&gt;&lt;input type="text" id="city"&gt;
                  &lt;label for="state"&gt;State&lt;/label&gt;&lt;input type="text" id="state"&gt;
                  &lt;label for="pin"&gt;PI`enter code here`N&lt;/label&gt;&lt;input type="text" id="pin"&gt;
                  &lt;input type="button" value="Add record" id="add" onclick=addRrecord();&gt;
                  &lt;input type="button" value="Update record" id="update"&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p><a href="http://jsfiddle.net/z9QdK/5/" rel="nofollow noreferrer">http://jsfiddle.net/z9QdK/5/</a>
          </p>
  
  <pre><code>  [1]: http://i.stack.imgur.com/mBQJv.gif
  </code></pre>