Results 1 to 7 of 7
  1. #1
    javasiva is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Post doubt on java along with javascript

    when a button is clicked iam getting new row in a table(using javascript).But how can i get the field values of the newly appended row?insertion into DB is happening for only first row.plz solve this its urgent

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,800
    Rep Power
    19

    Default

    You have given us nothing to work with here.
    No code or anything.

  3. #3
    javasiva is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    <script>
    function addRow(id) {

    var table = document.getElementById(id);

    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);

    var colCount = table.rows[0].cells.length;

    for(var i=0; i<colCount; i++) {

    var newcell = row.insertCell(i);

    newcell.innerHTML = table.rows[0].cells[i].innerHTML;
    //alert(newcell.childNodes);
    switch(newcell.childNodes[0].type) {
    case "text":
    newcell.childNodes[0].value = "worked";
    break;
    case "checkbox":
    newcell.childNodes[0].checked = false;
    break;
    case "select-one":
    newcell.childNodes[0].selectedIndex = 0;
    break;
    }
    }
    }



    function deleteRow(id) {
    try {
    var table = document.getElementById(id);
    var rowCount = table.rows.length;

    for(var i=0; i<rowCount; i++) {
    var row = table.rows[i];
    var chkbox = row.cells[0].childNodes[0];
    if(null != chkbox && true == chkbox.checked) {
    if(rowCount <= 1) {
    alert("Cannot delete all the rows.");
    break;
    }
    table.deleteRow(i);
    rowCount--;
    i--;
    }

    }
    }catch(e) {
    alert(e);
    }
    }
    </script>
    This is the script part which i was used to add or delete a row from the table.



    <table>
    <tr>
    <td>
    <form name="foo" action="time.do" method="post">
    <font color="brown" size="3" >Select Date:</font><input type="text" name="bar" /><a href="#" onclick="return getCalendar(document.foo.bar);"><img src="images/calendar.png" border="0" /></a>

    </td>
    <td>
    Project:
    <select name="project" id="projectid">
    <option value="documentum">Documentum</option>
    <option value="java">Java</option>
    <option value="dotnet">.Net</option>
    <option value="sharepoint">SharePoint</option>
    </select>
    </td>
    </tr>
    </table>
    <table >
    <tr bgcolor= #357EC7>
    <td width="11%"><font color="white">Task:</font></td>
    <td width="5%"><font color="white"> Status:</font></td>
    <TD width="5%"><font color="white">Start Time:</font></TD>
    <TD width="5%"><font color="white">Finish Time:</font></TD>
    <TD width="1%"><font color="white"> Total:</font></TD>

    </tr>
    </table>
    <!-- </table>
    <table>-->
    <table id="addrow" class="employee-report-table-row2">
    <tr>
    <td><input type="checkbox" name="checkbox" id="checkboxid"/></td>
    <td width="10%"><input type="textarea" rows="1" cols="30" name="task"/></td>
    <!--<td>
    <form name="assigned" method="post">
    Assigned:<input type="radio" name="taskyes" value="yes"/>yes
    <input type="radio" name="taskyes" value="no"/>no
    </form>
    </td>-->

    <td width="25%">

    <select name="status" class="status1">
    <option value="completed">Completed</option>
    <option value="pending">Pending</option>

    </select>
    </td>
    <!-- <form name="timevalue">-->
    <TD WIDTH="15%">

    <SELECT name=sh ID="sh"> <OPTION ID="op" value=00>00<OPTION
    value=01>01<OPTION value=02>02<OPTION value=03>03<OPTION
    value=04>04<OPTION value=05>05<OPTION value=06>06<OPTION
    value=07>07<OPTION value=08>08<OPTION value=09 selected>09<OPTION
    value=10>10<OPTION value=11>11<OPTION value=12>12<OPTION
    value=13>13<OPTION value=14>14<OPTION value=15>15<OPTION
    value=16>16<OPTION value=17>17<OPTION value=18>18<OPTION
    value=19>19<OPTION value=20>20<OPTION value=21>21<OPTION
    value=22>22<OPTION value=23>23</OPTION></SELECT> <SELECT name=sm ID="sm">
    <OPTION value=00 selected>00<OPTION value=05>05<OPTION value=10>10<OPTION
    value=15>15<OPTION value=20>20<OPTION value=25>25<OPTION
    value=30>30<OPTION value=35>35<OPTION value=40>40<OPTION
    value=45>45<OPTION value=50>50<OPTION value=55>55</OPTION></SELECT>
    </TD>
    <!--<TD valign=middle>Finish Time:(<INPUT type=checkbox
    name=plus24> Next day)--> </TD>
    <TD WIDTH="30%" ><SELECT name=fh ID="fh" > <OPTION value=00>00<OPTION
    value=01>01<OPTION value=02>02<OPTION value=03>03<OPTION
    value=04>04<OPTION value=05>05<OPTION value=06>06<OPTION
    value=07>07<OPTION value=08>08<OPTION value=09>09<OPTION
    value=10>10<OPTION value=11>11<OPTION value=12>12<OPTION
    value=13>13<OPTION value=14>14<OPTION value=15>15<OPTION
    value=16>16<OPTION value=17>17<OPTION value=18 selected>18<OPTION
    value=19>19<OPTION value=20>20<OPTION value=21>21<OPTION
    value=22>22<OPTION value=23>23</OPTION></SELECT> <SELECT name=fm ID="fm" ONCHANGE=" return hours(document.foo);">
    <OPTION value=00 selected>00<OPTION value=05>05<OPTION
    value=10>10<OPTION value=15>15<OPTION value=20>20<OPTION
    value=25>25<OPTION value=30>30<OPTION value=35>35<OPTION
    value=40>40<OPTION value=45>45<OPTION value=50>50<OPTION
    value=55>55</OPTION></SELECT>
    </TD>
    <!-- <TD >Time off for Breaks:</TD>
    <TD ><SELECT name=bh> <OPTION value=00 selected>00<OPTION
    value=01 SELECTED>01<OPTION value=02>02<OPTION value=03>03<OPTION
    value=04>04<OPTION value=05>05<OPTION value=06>06<OPTION
    value=07>07<OPTION value=08>08<OPTION value=09>09<OPTION
    value=10>10<OPTION value=11>11</OPTION></SELECT> <SELECT name=bm>
    <OPTION value=00>00<OPTION value=05>05<OPTION value=10>10<OPTION
    value=15>15<OPTION value=20>20<OPTION value=25>25<OPTION
    value=30>30<OPTION value=35>35<OPTION value=40>40<OPTION
    value=45>45<OPTION value=50>50<OPTION value=55>55</OPTION></SELECT>
    </TD>-->
    <TD > <input type="text" maxlength="2" name="totaltime" size="2" id="worked" / >
    hours.</TD>
    <!-- </form>-->
    </tr>
    </table>
    <table>
    <tr>
    <td>
    <input type="submit" value="submit">
    </TD>
    <td>
    <input type="button" value="Another Task" onclick="addRow('addrow')"/>
    </td>
    <td>
    <input type="button" value="Delete Task" onclick="deleteRow('addrow')"/>
    </td>
    </tr>
    </table>
    This was the code part.Here am able to insert only the first row but the other rows are not getting inserted into the DB.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,800
    Rep Power
    19

    Default

    Please use CODE tags.
    That's unreadable.

    What gets sent to the server?

  5. #5
    javasiva is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    sry iam not getting you

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Is there any part of your question that pertains to Java code?

    db

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 5
    Last Post: 06-17-2011, 12:31 AM
  2. Replies: 11
    Last Post: 08-18-2009, 04:31 AM
  3. JAva thread doubt
    By sunny_sykes in forum Advanced Java
    Replies: 8
    Last Post: 04-02-2009, 08:19 PM
  4. Java Swing JTable Simple Doubt
    By hemanthjava in forum AWT / Swing
    Replies: 1
    Last Post: 11-26-2008, 01:46 PM
  5. A great doubt in Java Applet,will u solve it!!
    By anithababu in forum Java Applets
    Replies: 6
    Last Post: 01-27-2008, 01:20 PM

Posting Permissions

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