I have a table that is built from a database, so its size is always variable depending on the account being requested. Once the page is rendered I use JQuery to add additional rows when the user clicks on a button. I want to use an index at the end of the ID and Name element, so that I can identify what row is being manipulated later in some other JQuery Logic and in the backend when a JAVAServlet gets the parameter names. (I.e. id="requestedInput" + rowCount = requestedInput1 or requestedInput2 etc. )
I’ve tried the below and a few other failed attempts, any wisdom?
Initializing rowCount to a space is bizarre, unnecessary, and confusing. In fact, its existence outside the handler is needless, and I'd say incorrect.
Your text blob of HTML has rowCount embedded as just part of the string. I assume you meant to use concatentation to assemble the final string interspersed with the value of rowCount. If so, you need to get the syntax right. E.g. 'string' + value + 'string', and not "string + value + string'
HTML blobs suck. If you are going to use one, at least format and indent it so that it is readable.
Please ask for clarifications as necessary. You're really close.
I didn't like the HTML blob idea either, but I searched the internet for an example of adding elements and that was one of the more popular examples. Can you give me a better idea, point me to a site or book?
I've read the Head First JQuery book all the way thru, but some things I'm trying to do. Are un-ordinary?
I haven't ready that book, but element creation is a fundamental part of jQuery, and not in the least out of the ordinary. It's covered pretty well in my jQuery in Action series.
It can get rather lengthy, but is also well-suited to abstractions and functional building of elements. But the big advantage is that there are no hard-to-read HTML blobs, and you can set attributes, properties and values via code easily.
P.S. Though, I will admit to using HTML blobs for short, static constructs at times. But never for anything like what you are doing.