What I have is this object.innerHTML which is this:
<TABLE >
<TBODY>
<TR>
<TD >
<IMG id=ctl00_Def_ctl00_ucXXXControl_gvGridName_ctl00_ctl05_imgXYZError src="etc/exclamation.png">
</TD>
<TD>
<SELECT id=ctl00_Def_ctl00_ucXXXControl_ctl00_ctl05_rcb123 name=ctl00$Def$ctl00$ucXXXControl$gvGridName$ctl00$ctl05$rcb123>
<OPTION value=0></OPTION>
<OPTION value=1>703</OPTION>
<OPTION value=3>704</OPTION>
<OPTION value=4>801</OPTION>
<OPTION value=5>802</OPTION> (etc)
</SELECT>
</TD>
</TR>
</TBODY>
</TABLE>
I need to know how to, via JavaScript, work with that innerHTML text blob. How would I get the “selectedIndex” of my select element?
More painful details, if you want this part:
I am working with a RadGrid control (from Telerik) and using the ‘in-line’ editing option. So this grid contains X rows, with each row having X cells. The contents of the cells are the issue. Each cell contains “stuff”. Some contain a simple “input” element, etc, but one I need to work with contains a table definition, that itself contains 1 row with 2 cells. One cell has an image, the other cell has a dropdown list, i.e. a “select” element.
My issue is I have used the RadGrid client API set so I can drill down to the cell. At this point they don’t really offer (that I can find) any way to work with the contents of that cell… probably because the contents can be anything. So I need to figure out how to work with this HTML string. Still new to jQuery and JavaScript… I really just want to cast the string as a table object and then run a jQuery selector against that object… but JavaScript doesn’t really work that directly… from what I can tell so far. 🙁
OK, the idea I had right after the post ended up being what I used, which is what shoebox639 suggested as well. I put the code to pull out the required clientID into a helper method:
So in my case I would pass in the rcb123 as the first parm, and the innerHTML string blob as the second value, and the function would return the clientID value. After getting the clientID back, I just do another jQuery method call using that:
I’m still testing various examples, and looking for any holes other than those noted, but for my purposes this works well. I created the helper routine because I also manipulate the image in the innerHTML blob as well.
The idea was to put an ‘error image’ next to each control in the grid for a visual ref to where the error was, but only add ONE error message to the errorSummary control, instead of X repeated error messages which I got when simply embedding a required field validator along side the dropdown list. (my BA group didn’t like that…)
Hope this helps somebody out.