0

I am trying to create and call a checkbox from another function. formatStudentColumn adds a checkbox to every row in the table.
After that I want to trigger markChecked function and work with the rowIndex variable but at this point its throwing:

ReferenceError: 00123 is not defined

Here 00123 is the actual value of rowIndex.

function markChecked(rowIndex){

 console.log("rowIndex: " + rowIndex);
  if(document.getElementById("student" + rowIndex ).checked)
 {
  //do something if its checked
 }
 else{
  // do something if its unchecked
 }

}


var formatStudentColumn = function(id){

    rowIndex = this.grid.getItem(id).studentId;
    return '<input type="checkbox" onClick="javascript:markChecked('+ rowIndex +')" id="student'+ rowIndex +'" />';

}
7
  • Are you sure the number is not truncated to 123 instead of 00123? Commented Mar 19, 2013 at 18:53
  • 4
    00123 looks more like a string than a number Commented Mar 19, 2013 at 18:54
  • console.log is printing 00123 Commented Mar 19, 2013 at 18:55
  • is this the last row? Commented Mar 19, 2013 at 18:55
  • 2
    Shouldn't it be spitting out "student00123" is not defined? What line does the error get thrown on? Commented Mar 19, 2013 at 18:55

1 Answer 1

1

Stab in the dark, I think you need to add some quotes to the click event.

onclick="markChecked(\''+ rowIndex +'\')"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.