Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ HIGHLIGHT NEXT HIGHER VALUE IN A TABLE CELL TO THE GIVEN VALUE

Posted by: shankar from vizag Aug 24 2022, 11:06 AM

Greetings

I have a table column (Current Level) and a textbox. If any value in the table column is supplied in the textbox, the same will be highlighted with the help of jQuery.

2. Here, I need the help to bold and highlight the next immediate higher value also to the given value.

Kindly guide me how to do the same using jQuery.Attached File  test.html ( 2.09k ) Number of downloads: 285


Regards

Posted by: Christian J Aug 24 2022, 02:12 PM

Greetings!

I don't do jQuery, so this is just some general javascript-based ideas:

QUOTE(shankar from vizag @ Aug 24 2022, 06:06 PM) *

I have a table column (Current Level) and a textbox. If any value in the table column is supplied in the textbox, the same will be highlighted with the help of jQuery.

The exact value or a partial value? Looking at the current script, it appears typing "63" will make "63100" become highlighted.

QUOTE
Here, I need the help to bold and highlight the next immediate higher value also to the given value.

Are all the values numbers? In that case you should first convert them to numbers (instead of strings), and then look for an exact match. Form field and innerHTML values are strings by default.

Finding the next immediate higher numerical value seems a bit tricky. One idea might be to first build an array of any cell values larger than the text field's, and then sort that array in order to find the lowest array value (which is the one immediately larger than the text field's).









Posted by: shankar from vizag Aug 24 2022, 07:42 PM

QUOTE(Christian J @ Aug 25 2022, 12:42 AM) *

Greetings!

I don't do jQuery, so this is just some general javascript-based ideas:

QUOTE(shankar from vizag @ Aug 24 2022, 06:06 PM) *

I have a table column (Current Level) and a textbox. If any value in the table column is supplied in the textbox, the same will be highlighted with the help of jQuery.

The exact value or a partial value? Looking at the current script, it appears typing "63" will make "63100" become highlighted.

QUOTE
Here, I need the help to bold and highlight the next immediate higher value also to the given value.

Are all the values numbers? In that case you should first convert them to numbers (instead of strings), and then look for an exact match. Form field and innerHTML values are strings by default.

Finding the next immediate higher numerical value seems a bit tricky. One idea might be to first build an array of any cell values larger than the text field's, and then sort that array in order to find the lowest array value (which is the one immediately larger than the text field's).



Thank you christian J. for your guidance. Let me try.

Posted by: Christian J Aug 25 2022, 11:08 AM

How is the table generated? If it comes from a database, maybe you could sort the table data already in the DB query.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)