www.webdeveloper.com
Results 1 to 2 of 2

Thread: Basic question on syntax

Hybrid View

  1. #1
    Join Date
    Aug 2013
    Posts
    1

    Basic question on syntax

    Really basic question
    I have a function that inserts a new row into a table with different cells. Cell one(or 0) is my delete function to delete that row.

    Code:
    var cell1 = row.insertCell(0);
    cell1.style.textAlign = 'left';
    cell1.innerHTML = "<a onClick=\"deleteRow('dataTable', this.parentNode.parentNode.rowIndex)\" align=\"left\"> Remove this Guest</a>";
    This calls my delete function

    Code:
      function deleteRow(tableID, row) {
                try {
                var table = document.getElementById(tableID);
                var rowCount = table.rows.length;
                table.deleteRow(row);
                }catch(e) {
                    alert(e);
                }
    In my statement where I declare my "onClick" how can I pass a variable into my function call instead of "dataTable"?
    I've tried a few different ways, but I cant seem to get it to work.

  2. #2
    Join Date
    Jul 2013
    Posts
    66
    Code:
    var foo = "World",
        bar = "Hello " + foo + "!";
    alert(bar);
    See Expressions and operators – String operators (MDN)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles