javascript onclick function not working in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mohamed abdul
    New Member
    • Dec 2010
    • 2

    javascript onclick function not working in IE

    am working with that code, when i click addrow button onclick function is not working in IE but working in mozilla, chrome

    code is

    <td><INPUT type="button" value="Add Row" onClick="addRow ('dataTable')" class="btnExamp le" style="width:70 px;"/></td>

    <td><INPUT type="button" value="Delete Row" onClick="remove Row('dataTable' )" class="btnExamp le" style="width:85 px;"/></td>

    </tr>
    </table>

    <table id="dataTable" style="margin-right:auto">

    <tr>


    <td>
    <?php $result = mysql_query("se lect customer from customer"); echo "<select name = \"customervisit 1\" style=\"width:1 25px;\">\n"; while ($row = mysql_fetch_ass oc($result)) { echo '<option value = "'.$row[customer].'">'.$row[customer].'</option>';} echo "</select>"; ?>
    </td>

    <td><input type="checkbox" name="chk1[]" value="mon," style="width:65 px;"></td>

    <td width="29"><inp ut type="checkbox" name="chk1[]" value="tue," style="width:65 px;"></td>

    <td width="35"><inp ut type="checkbox" name="chk1[]" value="wed," style="width:65 px;"></td>

    <td width="31"><inp ut type="checkbox" name="chk1[]" value="thu," style="width:65 px;"></td>

    <td width="24"><inp ut type="checkbox" name="chk1[]" value="fri," style="width:65 px;"></td>

    <td width="140"><in put class="input" type="text" name="pvdescrip tion1" value="<?php if(isset($_POST['pvdescription'])) { echo $_POST['pvdescription'];} ?>" style="width:12 5px;" ></td>




    </tr>



    </table>


    javascript function is

    function addRow(tableID) {
    var rowid = parseInt(docume nt.getElementBy Id('customerro' ).value)+1;

    var content='';
    content +='<td>';
    content +='<select name="customerv isit'+rowid+'" type="text" id="customervis it'+rowid+'" class="inputt" value = "" style="width:12 5px;">';
    content +='<option value="" >-- select --</option>';
    content +='<?php echo $customer; ?>';
    content +='</select>';
    content +='</td>';
    content +='<td><input type="checkbox" name="chk'+rowi d+'[]" value="mon," style="width:65 px;"></td>';
    content +='<td width="29"><inp ut type="checkbox" name="chk'+rowi d+'[]" value="tue," style="width:65 px;"></td>';
    content +='<td width="35"><inp ut type="checkbox" name="chk'+rowi d+'[]" value="wed," style="width:65 px;"></td>';
    content +='<td width="31"><inp ut type="checkbox" name="chk'+rowi d+'[]" value="thu," style="width:65 px;"></td>';
    content +='<td width="24"><inp ut type="checkbox" name="chk'+rowi d+'[]" value="fri," style="width:65 px;"></td>';
    content +='<td width="140"><in put type="text" class="input" name="pvdescrip tion'+rowid+'" value="" style="width:12 5px;" ></td>';
    content +='';
    document.getEle mentById('custo merro').value = rowid;
    var table = document.getEle mentById(tableI D);

    var rowCount = table.rows.leng th;
    var row = table.insertRow (rowCount);
    row.innerHTML = content;
    }
    function removeRow(table ID)
    {
    // grab the element again!
    var tbl = document.getEle mentById(tableI D);
    // grab the length!
    var lastRow = tbl.rows.length ;
    // delete the last row if there is more than one row!
    if (lastRow > 1) tbl.deleteRow(l astRow - 1);

    var rowid = parseInt(docume nt.getElementBy Id('customerro' ).value)-1

    document.getEle mentById('custo merro').value = rowid;
    }
    </script>
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi,
    Please update ur code like the below one.

    Code:
    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);
    row.innerHTML = content;
    if(window.ActiveXObject)
       row.innerHTML = row.innerHTML;
    }
    It's not a proper way to do. But this will help ur problem. This is to refresh the container.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • Mohamed abdul
      New Member
      • Dec 2010
      • 2

      #3
      ramanan, Thanks for yr reply its also not working in IE but i have changed my code like below


      content1 ='<select name="customerv isit'+rowid+'" type="text" id="customervis it'+rowid+'" class="inputt" value = "" style="width:12 5px;">';
      content1 +='<option value="" >-- select --</option>';
      content1 +='<?php echo $customer; ?>';
      content1 +='</select>';

      content2 ='<input type="checkbox" name="chk'+rowi d+'[]" value="mon," style="width:65 px;">';
      content3 ='<input type="checkbox" name="chk'+rowi d+'[]" value="tue," style="width:65 px;">';
      content4 ='<input type="checkbox" name="chk'+rowi d+'[]" value="wed," style="width:65 px;">';
      content5 ='<input type="checkbox" name="chk'+rowi d+'[]" value="thu," style="width:65 px;">';
      content6 ='<input type="checkbox" name="chk'+rowi d+'[]" value="fri," style="width:65 px;">';
      content7 ='<input type="text" class="input" name="pvdescrip tion'+rowid+'" value="" style="width:12 5px;" >';


      var rowCount = table.rows.leng th;
      var newRow = table.insertRow (rowCount);

      newCell = newRow.insertCe ll(0)
      newCell.innerHT ML = content1

      newCell = newRow.insertCe ll(1)
      newCell.innerHT ML = content2

      newCell = newRow.insertCe ll(2)
      newCell.innerHT ML = content3

      newCell = newRow.insertCe ll(3)
      newCell.innerHT ML = content4

      newCell = newRow.insertCe ll(4)
      newCell.innerHT ML = content5

      newCell = newRow.insertCe ll(5)
      newCell.innerHT ML = content6

      newCell = newRow.insertCe ll(6)
      newCell.innerHT ML = content7
      Its working properly,

      once again thanks

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Glad that you fixed by yourself. Great! Keep going.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        Working...