简体   繁体   中英

HTML tag attribute referenced to an object

I have an object that acts like a cursor(table) and it's like this:

function cursor() {
  this.code = "";
  this.name = ""; }

Then I have a variable that will be used as the cursor itself:

var lib_book = new cursor();

Then I have a table with a custom attribute 'record_source' which is referenced to my cursor:

<table record_source="lib_book" id="grdbook">

Now I have a Refresh_Record function that binds the cursor to the table object. I can do it with this code: (sorry for not including all the codes)

Refresh_Record(lib_book,grdbook);

Now the question is this, is there a way to change the code to this:

Refresh_Record(grdbook);

since I have lib_book as an attribute. But lib_book is just a string there. Is there a way that I can reference the record_source attribute to the actual cursor?

Save all your cursors in a global array, and save array index of cursor as attribute in table.

you can do it other way by using eval,but using eval is not a good idea

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM