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 186285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:37:12+00:00 2026-05-11T15:37:12+00:00

I’ve written the JQuery below, and have had to search for items in the

  • 0

I’ve written the JQuery below, and have had to search for items in the DOM using multiple calls to .parent() because the ClientIDs rendered in ASP.Net are built up dynamically in the html. I’m aware that this will cause problems each time we change the markup code, and would like to see if anyone knows of a better way to do this in ASP.Net.

<script language='jquery' src='js/jquery-1.3.2-vsdoc2.js' type='text/javascript'> </script> <script src='js/jquery.color.js' type='text/javascript'> </script> script language='javascript' type='text/javascript'>     $(document).ready(function() {      //Get the cost of the base item, then add the cost of the selected compoents as      //they get selected.         $('.AspNet-CheckBoxList > ul > li > input').click(function() {          var itemCost = 0;          $(this).find('fieldset:div:span');          itemCost =  GetItemCost($(this).parent().parent().parent().parent()         .parent().parent().parent().children().find('span').text());         var Component = $(this).next('label').text();          if ($(this).attr('checked') == true) {             itemCost = (itemCost + GetItemCost(Component)).toFixed(2);                        }         else {             itemCost = (itemCost - GetItemCost(Component)).toFixed(2);         }          $(this).parent().parent().parent().parent().parent()         .parent().parent().children().find('span').text('$' + itemCost);         $(this).parent().parent().parent().parent().parent()         .parent().parent().children().find('span').animate(          { backgroundColor: '#FFFF66' }, 300)          .animate({ backgroundColor: 'white' }, 750);       });     });  function GetItemCost(text) {     var start = 0;     start = text.lastIndexOf('$');      var itemCost = text.substring(start + 1);             var pattern = /,/g;     itemCost = itemCost.replace(pattern, '');             return Number(itemCost); } </script> 

Here is some of the html copied from the source of the rendered page

<fieldset id='ctl00_ContentPlaceHolder1_ctl00_FieldSet' class='parent'> <legend> </legend> <a id='ctl00_ContentPlaceHolder1_ctl00_ImgLink' class='imgcontainer'> </a> <div> <input id='ctl00_ContentPlaceHolder1_ctl00_RemoveCartItem' type='image'      alt='Remove Item' src='img/buttons/remove_4c.gif'      name='ctl00$ContentPlaceHolder1$ctl00$RemoveCartItem'/> <span id='ctl00_ContentPlaceHolder1_ctl00_TotalItemCost'>$315.96</span> </div> <ol id='ctl00_ContentPlaceHolder1_ctl00_InputList'> <li class='pt'> <label id='ctl00_ContentPlaceHolder1_ctl00_ProjectLabel'    for='ctl00_ContentPlaceHolder1_ctl00_ProjectValue'>Project</label> <input id='ctl00_ContentPlaceHolder1_ctl00_ProjectValue' type='text'   name='ctl00$ContentPlaceHolder1$ctl00$ProjectValue'/> </li> <li class='pt'> <label id='ctl00_ContentPlaceHolder1_ctl00_TaskLabel'     for='ctl00_ContentPlaceHolder1_ctl00_TaskValue'>Task</label> <input id='ctl00_ContentPlaceHolder1_ctl00_TaskValue' type='text'   name='ctl00$ContentPlaceHolder1$ctl00$TaskValue'/> </li> <li id='ctl00_ContentPlaceHolder1_ctl00_ComponentsLI'> <span>Specify</span> <fieldset id='ctl00_ContentPlaceHolder1_ctl00_ComponentsFieldSet'   class='fieldsetlist'> <legend>Software Components</legend> <div id='ctl00_ContentPlaceHolder1_ctl00_SoftwareComponentsCheckList' class='AspNet-  CheckBoxList'> <ul class='AspNet-CheckBoxList-RepeatDirection-Vertical'> <li class='AspNet-CheckBoxList-Item'> <input id='ctl00_ContentPlaceHolder1_ctl00_SoftwareComponentsCheckList_0'   type='checkbox' value='2305'      name='ctl00$ContentPlaceHolder1$ctl00$SoftwareComponentsCheckList$0'/> <label for='ctl00_ContentPlaceHolder1_ctl00_SoftwareComponentsCheckList_0'>Another   Cool Component $1,000.00</label> </li> <li class='AspNet-CheckBoxList-Item'> <input id='ctl00_ContentPlaceHolder1_ctl00_SoftwareComponentsCheckList_1'   type='checkbox' value='2306'    name='ctl00$ContentPlaceHolder1$ctl00$SoftwareComponentsCheckList$1'/> <label for='ctl00_ContentPlaceHolder1_ctl00_SoftwareComponentsCheckList_1'>Software    Assurance $274.89</label> </li> </ul> </div> </fieldset> </li> </ol> </fieldset> 
  • 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. 2026-05-11T15:37:13+00:00Added an answer on May 11, 2026 at 3:37 pm

    You can use the attribute ends with selector:

    $('tag[id$='ServerSideId']')  

    Where ServerSideId is the id used on server side.

    For example to select:

    <li id='ctl00_ContentPlaceHolder1_ctl00_ComponentsLI'> 

    Use:

    $('li[id$='ComponentsLI']')  
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I have two tables with like below codes: Table: Accounts id | username |
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.