Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem in popup calender in Dynamically loading Rows in java script

    I have written this code but when i include code for pop calender in a row, then button was disabled, So please help me i just struck in this problem from last one week
    Thanking you,
    L.Rajesh
    rajboy13@gmail.com

    my code is

    Code:
    function addRow()
    {
    var tbl = document.getElementById('tblMed');
    var lastRow = tbl.rows.length;
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    
     var cellLeft = row.insertCell(0);
      var sl = document.createElement('input');
      sl.type = 'text';
      sl.name = 'sln' ;
      sl.id = 'sln' + iteration;
      sl.value = iteration;
      sl.size = 3;
      sl.readOnly = true;
      cellLeft.appendChild(sl);
    
    var cellRights= row.insertCell(1);
    var elm= document.createElement('input');
    elm.type = 'text';
    elm.name = 'txtMdesc' ;
    elm.id = 'Mdesc' + iteration;
    elm.size = 20;
    cellRights.appendChild(elm);
    
    var cellRightt= row.insertCell(2);
    var elmn= document.createElement('input');
    elmn.type = 'text';
    elmn.name = 'txtMqty' ;
    elmn.onclick = "cal1xx.select(document.forms[0].sdate,'anchor1xx','dd-MM-yy');
    elmn.id = 'Mqty' + iteration;
    elmn.size = 20;
    cellRightt.appendChild(elmn)";
    
    var cellRightu= row.insertCell(3);
    var elmno= document.createElement('input');
    elmno.type = 'text';
    elmno.name = 'txtMbill' ;
    elmno.id = 'Mbill' + iteration;
    elmno.size = 20;
    cellRightu.appendChild(elmno);
    
    }
    the button code is :
    Code:
    </br>
     <fieldset style="width:60%;" align="center"> <legend>
    
    
    <SCRIPT LANGUAGE="JavaScript">
    function deleteRow(b){
        document.getElementById('table_formcontainer').deleteRow(b)
    }
    function CompareDates1() 
    { 
    	var str1  = document.getElementById("start").value;   
    	var str2  = document.getElementById("edate").value;  
    	var dt1   = parseInt(str1.substring(0,2),10);    
    	var mon1  = parseInt(str1.substring(3,5),10);  
    	var yr1   = parseInt(str1.substring(6,10),10);   
    	var dt2   = parseInt(str2.substring(0,2),10);    
    	var mon2  = parseInt(str2.substring(3,5),10);   
    	var yr2   = parseInt(str2.substring(6,10),10);   
    	var date1 = new Date(yr1, mon1, dt1);    
    	var date2 = new Date(yr2, mon2, dt2);    
    	if(date2 < date1)  
    		{      
    			alert("To date cannot be greater than from date");      
    			return false;   
    		}    
    	else   
    		{      
    			alert("Submitting ...");     
    			document.form1.submit();   
    		} 
    		return true;
    }
    function addRow()
    {
    var tbl = document.getElementById('tblMed');
    var lastRow = tbl.rows.length;
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    
     var cellLeft = row.insertCell(0);
      var sl = document.createElement('input');
      sl.type = 'text';
      sl.name = 'sln' ;
      sl.id = 'sln' + iteration;
      sl.value = iteration;
      sl.size = 3;
      sl.readOnly = true;
      cellLeft.appendChild(sl);
    
    var cellRights= row.insertCell(1);
    var elm= document.createElement('input');
    elm.type = 'text';
    elm.name = 'txtMdesc' ;
    elm.id = 'Mdesc' + iteration;
    elm.size = 20;
    cellRights.appendChild(elm);
    
    var cellRightt= row.insertCell(2);
    var elmn= document.createElement('input');
    elmn.type = 'text';
    elmn.name = 'txtMqty' ;
    elmn.onclick = "cal1xx.select(document.forms[0].sdate,'anchor1xx','dd-MM-yy');
    elmn.id = 'Mqty' + iteration;
    elmn.size = 20;
    cellRightt.appendChild(elmn)";
    
    var cellRightu= row.insertCell(3);
    var elmno= document.createElement('input');
    elmno.type = 'text';
    elmno.name = 'txtMbill' ;
    elmno.id = 'Mbill' + iteration;
    elmno.size = 20;
    cellRightu.appendChild(elmno);
    
    }
    
    function delRow1(c)
    {
        document.getElementById('tblMed').deleteRow(c)
    }
    
    function validate()
    {
    	
    	var tbl = document.getElementById('tblMed');
        var lastRow= tbl.rows.length-1;
       	var a;
    
        for (a=1; a<=lastRow; a++)
    		{
          var def = document.getElementById('sln'+ a);
          var ghi = document.getElementById('Mdesc'+ a);
    	   var jkl = document.getElementById('Mqty'+ a);
    	   var jkl1 = document.getElementById('Mqty'+ a).value;
           var abc = document.getElementById('Mbill'+ a);
           var gpexpdt2 = document.getElementById('tblMed').value;
          var str11  = document.getElementById("sdate").value; 
          var str12  = document.getElementById("edate").value;
    	  var tranday = jkl1.substring(0,2);
          var tranmon = jkl1.substring(3,5);
          var tranyear = jkl1.substring(6,10);
    	
    
    
    	var trandate = new Date(tranyear,tranmon,tranday);
    	 var tranday2 = str11.substring(0,2);
    	  
              var tranmon2 = str11.substring(3,5);
             
    
    
    	var tranyear2 = str11.substring(6,10);
    	
    
    
    	var trandate2 = new Date(tranyear2,tranmon2,tranday2);
    	var tranday3 = str12.substring(0,2);
    	  
              var tranmon3 = str12.substring(3,5);
             
    
    
    	var tranyear3 = str12.substring(6,10);
    	
    
    
    	
    if ((document.getElementById("AC").value == ""))
    {
    alert ( "Please enter Amount Claimed." );
    document.form5.AC.focus();
    return false;
    }
    
    else if((document.getElementById("Amb").value == ""))
    {
    alert ( "Please enter Relationship" );
    document.form5.Amb.focus();
    return false;
    }
    
    if ( document.form5.Treat.selectedIndex == "")
        {
            alert ( "Please select Treatment Type" );
    		document.form5.Treat.focus();
            return false;
        }
    
    else if((document.getElementById("C10").value == ""))
    {
    alert ( "Please enter Total " );
    document.form5.C10.focus();
    return false;
    }
    
    else if((document.getElementById("C11").value == ""))
    {
    alert ( "Please enter Place " );
    document.form5.C11.focus();
    return false;
    }
    
    else if((document.getElementById("start").value == ""))
    {
    alert ( "Please enter from date" );
    document.form5.start.focus();
    return false;
    }
    
    else if((document.getElementById("edate").value == ""))
    {
    alert ( "Please enter to date" );
    document.form5.edate.focus();
    return false;
    }
        if (ghi.value.length == "")
    	  {
            alert('Please enter Bill No');
            ghi.focus();
    
            return false;
          }
    	  if (jkl.value.length == "")
    	  {
            alert('Please enter Date');
    	   jkl.focus();
            return false;
          }
    	  var trandate3 = new Date(tranyear3,tranmon3,tranday3);
    	if (tranmon > 12|| tranmon < 1)
    		 {
    			 alert('Invalid Month In Date Field .Enter as dd-mm-yy');
            	jkl.focus();
    			 return false;
    		 }
    		 if (tranday > 31|| tranday < 1)
    		 {
    			 alert('Invalid Date In Date Field Enter as dd-mm-yy');
    			 		jkl.focus();
    			 return false;
    		 }
    		 if(trandate2.getTime() > trandate.getTime())
    			{
    	alert("Bill date should be less than From date");
    	jkl.focus();
    	return false;
    			}
    			if(trandate3.getTime() < trandate.getTime())
    			{
    	alert("Bill date should not  be greater than End date");
    	jkl.focus();
    	return false;
    			}
    	
         if (abc.value.length == "")
    	  {
            alert('Please enter Amount');
    	    abc.focus();
            return false;
          }
    	  	
    	 
    var str3  = document.getElementById("AC").value;
    var str4  = document.getElementById("Amb").value;
    
    if(parseInt(str3) > parseInt(str4))
    {
    alert('Amount Claimed must be less than Amount Balance');
    document.form5.AC.focus();
    return false;
    }	
    var alertsay = ""; 
    if (form5.Treat.value > 4)
    {
    alert("Sorry You Can Not This Employee Data In Database..........");
    form5.Treat.focus();
    return (false);
    }
    var checkOK = "0123456789";
    var checkStr = abc.value;
    var allValid = true;
    var allNum = "";
    for (e = 0;  e < checkStr.length;  e++)
    {
    ch = checkStr.charAt(e);
    for (f = 0;  f < checkOK.length;  f++)
    if (ch == checkOK.charAt(f))
    break;
    
    if (f == checkOK.length)
    {
    allValid = false;
    break;
    }
    if (ch != ",")
    allNum += ch;
    }
    if (!allValid)
    {
    alert("Invalid Data Please enter only digits'");
    abc.focus();
    return (false);
    }
    }
     return true;
    }
    var count =0;
    function Check()
    	{
    if (!validate())
    	return true;
    	 addRow()
    	}
    function removeRow1()
    {
    var tbl = document.getElementById('tblMed');
    var lastRow = tbl.rows.length;
    if (lastRow > 1) tbl.deleteRow(lastRow - 1);
    }
    function deleteRow(node) {
    if (rowNum > 1) {
    var td = node.parentNode; 
    while (td.tblMed.toLowerCase() != "tr") 
    td = td.parentNode; 
    td.parentNode.removeChild(td); 
    rowNum = rowNum - 1;
    document.form1.count.value = rowNum;
    }
    else { 
    alert ("You cannot delete the last remaining row");
    } 
    }
    
    </script>
    
    <b><font color="#153E7E"border="1">Bill Details</b></legend><br>
    <table id="tblMed" width="75%">
    <tr>
    <th>Sl.No.</th>
    <th align="left">Bill No</th>
    <th align="left" onClick="cal1xx.select(document.forms[0].edate,'anchor1xx','dd-MM-yy'); return false;" NAME="anchor1xx" ID="anchor1xx" onFocus="self.status='Select Treatment Start Date';return true; " onBlur="self.status='';return true;">Bill Date(DD-MON-YY)</th>
    <th>Bill Amount( <span class="WebRupee">Rs.</span> )</th>
    
    </tr>
    
    </table>
    <tr><br/>
    &nbsp &nbsp <input name="button" type="button" value="Add  Bill" onClick="Check()"/>


    ................................................................................................



    i want popup calender in 3rd row of the table

    please help and if any one got solution then please please mail it to my gmail id : rajboy13@gmail.com
    Last edited by VIPStephan; 05-08-2012 at 05:28 PM. Reason: added code BB tags

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    When posting code, please put it in between [CODE][/CODE] tags. It makes scanning your posts much easier. You can do this by clicking the small ‘#’ icon above the reply field.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •