Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3318318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:41:29+00:00 2026-05-17T22:41:29+00:00

What I have is this object.innerHTML which is this: <TABLE > <TBODY> <TR> <TD

  • 0

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. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:41:30+00:00Added an answer on May 17, 2026 at 10:41 pm

    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:

        //****************************************************************************************
    //* Find a requested control's clientID as the first parm passed in from a string 
    //*    passed in as the second parm. 
    //****************************************************************************************
        function locateClientID(requestedClientID, HTML_StringToSearch) {
        var returnValue = "";
    
        //If we have something to search for and something to search in, do so.  Null or "" will fail this check.
        if (requestedClientID && HTML_StringToSearch) {
    
            //Find the starting point of the string starting with "id=", then any number of other letters, numbers,
            //  or underscores, then ending in the specified "requestedClientID" parm value.  We add three to offset
            //  the "id+" part of the search string, which we don't want in the results, but include to locate value.
            var startingPoint = HTML_StringToSearch.search("id=[a-z0-9A-Z_]*" + requestedClientID) + 3;
    
            //If we found a valid starting point, i.e. NOT -1, then continue processing the string.
            if (startingPoint > -1) {
    
                //Now that we know where our clientID for the requested control starts in the passed in string,
                //  find the ending " " so we know how much to substr off to pull out the requested client id.
                var endingPoint = HTML_StringToSearch.indexOf(" ", startingPoint);
                //The endingPoint could be -1 if there is no space after the "id" property, but all the examples
                //  I have seen have more attributes after.
    
                //substr out the clientID and return it to the caller.
                returnValue = HTML_StringToSearch.substr(startingPoint, (endingPoint - startingPoint));
             }
        }
    
        return returnValue;
    }
    //*****************************************************************************************
    

    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:

    function cv123_Validate(sender, eventArgs) {
    
        //Get a ref to the radGrid's collection of rows.
        var gvRadGridNameRows = $find("<%= gvRadGridName.ClientID %>").MasterTableView.get_dataItems();
    
        var innerHTML;
        var foundClientID;
        var errorImage;
        var rcb123;
    
        //Process every row in the radGrid.
        for (var row = 0; row < gvRadGridNameRows.length; row++){
            //Get the cell in question's innerHTML value.
            innerHTML = gvRadGridNameRows.get_cell("uniqueCellName").innerHTML;
    
            //Get ref to the 'error image'.
            errorImage = $("#" + locateClientID("imgHUDError", innerHTML));
    
            //locate the unique clientID of the rcb123 in this row.
            foundClientID = locateClientID("rcb123", innerHTML);
    
            //Use the found unique clientID with jQuery to get a ref to the dropdown list.
            rcb123 = $("#" + foundClientID)[0];
    
            //If the dropdown list's selected index is 0 or less AND the control is NOT 
            //  disabled, active the single error message tied to this custom validator
            //  and show the 'error image' next to the control.
            if (rcb123.selectedIndex < 1 && rcb123.isDisabled != true) {
                errorImage.css("height", 12);
                eventArgs.IsValid = false;
            }
            else //Otherwise, hide the error image.
            {
                errorImage.css("height", 0);  
            }
        }
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this ListBox which is bound to an ObservableCollection. Each object in the
I have this object: var count = { table: 15, people: 34, places_details: 85,
I have this object graph, I want to map: abstract Account (username, password, ...)
In my qt app I have this object, filled before setting up my QTreeWidget's
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
Suppose I have a design like this: Object GUI has two objects: object aManager
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
So, I have this situation where I need to see if an object is
The situation is this: You have a Hibernate context with an object graph that
Imagine this case where I have an object that I need to check a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.