assign values to a table from javascript in VF page

JavaScript
<apex:page standardController="Application__c" extensions="applicationformcontrol" id="pg1" sidebar="false">
<apex:form id="frm1">
<!—- To enable or disable the checkbox -->
<apex:inputField id="check" value="{!app.Checksamepresent__c}" onchange=" return check();"/> 
</apex:form>
<!-- Javasript functionality-->
<script>
<!-- To display or hide the output panel based on the country selection for dependent country picklist or textbox -->
function check()
{
var con=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.precon}").value;
var conp=document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.percon}").value;
if(document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.check}").checked==true)
{
if(con=="United States")
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
else
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
}
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").value=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.preadd1}").value;
<!-- Same as Present Address, Permanent Address fields are read only -->
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").readOnly=true;
}
else
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").value='';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.peradd1}").readOnly=false;
}
}
<!-- To display or hide, dependent picklist or text box field based on country selection -->
function change()
{
var country=document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.precon}").value;
if(country=='United States')
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p1}").style.display = 'block';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p2}").style.display = 'none';

}
else
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p1}").style.display = 'none';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs1.p2}").style.display = 'block';
}
}
function change1()
{
var country=document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.percon}").value;
if(country=='United States')
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'block';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'none';
}
else
{
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p3}").style.display = 'none';
document.getElementById("{!$Component.pg1.frm1.pbk.pbs2.p4}").style.display = 'block';
}
}
</script>
</apex:page>

Source

Also in JavaScript: