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

  • Home
  • SEARCH
  • 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 6629971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:14+00:00 2026-05-25T22:20:14+00:00

Below is the code, the program is split into two main segments. One that

  • 0

Below is the code, the program is split into two main segments.
One that performs operation on each Select element and the other
on all the option elements within this\each select and this one
does not work as it should append a price “[+$00]” to each select option text value,
bar the currently selected one. The piece of code that does not work is tagged.
Worked fine with 1.5.1, 1.5.2 and does not work with all starting from 1.6

        // ===== CODE DOES NOT WORK FROM HERE WITH 1.6.4============
        $(this).find('option').each(function () {

            //$(this).append('<span></span>');

            var uov = parseInt($(this).attr('value')) || 0; //Unselected option value

            var uop; //Unselected Option Price


            for (d = 0; d <= data.length; d++) {


                if (data[d].partid == uov) {

                    uop = data[d].price;
                    break;
                }

            }

            //debugger;
            var pricediff = Math.abs(uop - sop);

            var xtext = $(this).text();





            if (xtext.match(/\✔/) != null) {

                var temp = xtext.replace(/✔/g, '');


                xtext = temp;
            }


            if (xtext.match(/\[.*\]/) != null) {
                var temp = xtext.split('[')[0];
                var temp2 = xtext.split(']')[1];

                xtext = temp2;
            }

            if (uov != 0) {

                if (pricediff != 0) {


                    var diff = '[' + (sop > uop ? '-' : '+') + '$' + pricediff + ']';


                    $(this).attr("text", diff + " " + xtext);
                }

                else {

                    $(this).attr("text", "  ✔  " + " " + xtext);


                }

            }

                  //=============== TO HERE ========================
  • 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-25T22:20:14+00:00Added an answer on May 25, 2026 at 10:20 pm

    Don’t use:

    $(this).attr('value')
    

    to get the value of a form field. Use:

    $(this).val()
    

    This has caused many headaches with our client developers when we changed our framework’s jQuery version.

    — Edit —

    You most certainly should not be trying to edit the text of an element with the attr() function as you have here:

     $(this).attr("text", diff + " " + xtext);
    

    You should use:

     $(this).text(diff + " " + xtext);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
I want to write two program(.h and .cpp) with below code and use .h
below i have a code that runs in most of my simple programs ..
My below code works fine and is used to populate a <select> item with
The below code works when there are a few element in the To list
There are two large text files (Millions of lines) that my program uses. These
I have a simple MFC program which displays the progressbar..I used the below code
How could I modify the below code such that I could, for better readability
The below code is extraction from a Java program. The program code is very
For a while now the installer for my program has used the below code

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.