Question: Dynamically added Row is Invisible in another javascript function..?

Ads

 
 
 

Share on Google+Share on Google+

Rags
Dynamically added Row is Invisible in another javascript function..?
0 Answer(s)      4 years and 10 months ago
Posted in : JavaScript Questions

I have table as below, I need to create 5 default rows, ( this is fine with below code)..but when add row its creating row in a table, but the created row is not visibile in another java script function. scripts are pasted at the bottom. please help me.

<table border='0' cellpadding=3 cellspacing=1 align="left" width="80%"
        id="dtlstable"
        style="border-width: 1px; border-color: #000000; border-style: solid;">

        <tr>
            <td align="left">First Name</td>
            <td align="left">Last Name</td>
            <td align="left">Email ID</td>
            <td align="left">Delete</td>
        </tr>
        <logic:present scope="request" name="searchDetail">
            <logic:empty scope="request" name="searchDetail">
                <%
                    for (int i = 1; i <= 5; i++) {
                %>
                <tr>
                    <td align="left"><html:text styleId='<%="fNameId"+i%>'
                        property="comForm.fName" value='${detail.fName}'
                        onkeypress="return check(event)" onkeyup="upperCase(this.id)"
                        styleClass="regTextbox" /></td>
                    <td align="left"><html:text styleId='<%="lNameId"+i%>'
                        property="comForm.lName" value='${detail.lName}'
                        onkeypress="return check(event)" onkeyup="upperCase(this.id)"
                        styleClass="regTextbox" /></td>
                    <td align="left"><html:text styleId='<%="eMailId"+i%>'
                        property="comForm.emailID" value='${detail.emailID}'
                        onkeypress="return check(event)" onchange="checkEmail(this.id)"
                        styleClass="regTextbox" /></td>
                </tr>
                <%
                    }
                %>
            </logic:empty>
        </logic:present>

function addRow(tableID) {

    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    i = rowCount;

    var tBody = table.getElementsByTagName('tbody')[0];
    var newTR = document.createElement('tr');
    var newTD1 = document.createElement('td');
    var newTD2 = document.createElement('td');
    var newTD3 = document.createElement('td');

    newTD1.innerHTML="<INPUT type= 'text' styleId='fName"+i+"' name='comForm.fName' value='' onkeypress='return check(event)' onkeyup='upperCase(this.id)' class='regTextbox' />";


    newTD2.innerHTML="<INPUT type= 'text' styleId='lName"+i+"' name='comForm.lName' value='' onkeypress='return check(event)' onkeyup='upperCase(this.id)' class='regTextbox' />";

    newTD3.innerHTML="<INPUT type= 'text' styleId='eMailId"+i+"' name='comForm.emailID' value='' onkeypress='return check(event)' onkeyup='upperCase(this.id)' class='regTextbox' />";

    newTR.appendChild (newTD1);
    newTR.appendChild (newTD2);
    newTR.appendChild (newTD3);
    tBody.appendChild(newTR);
}

function saveAll(tableID) {

    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;

    var saveEmails = "";
    alert(rowCount);
     for ( k=1; k<=rowCount-1; k++){
         alert(document.getElementById('fNameId'+k).value);
         if( document.getElementById('fNameId'+k).value!='' && document.getElementById('lNameId'+k).value && document.getElementById('eMailId'+k).value!=''){
             saveEmails += document.getElementById('fNameId'+k).value +"~"+
                        document.getElementById('lNameId'+k).value +"~"+
                        document.getElementById('eMailId'+k).value +"^";
         }
     }

     document.getElementById('methoId').value = "saveEmails" ;
     document.getElementById('saveEmailsId').value = saveEmails ;
    // document.getElementById('communicationFormId').submit();
     document.forms[0].submit();
}
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Advertisements
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads