The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> HTML5 Reference to from "List", List is getting way to big
Dohm
post Jun 3 2020, 09:38 AM
Post #1





Group: Members
Posts: 6
Joined: 3-June 20
Member No.: 27,374



Brand new to this site and to the wonderful world of coding and creating. I thank you all for any help.

I have created a simple site, well which I use as my personal server. That is not the issue as the site works.

I have a search list, which I add more and more each day... Have about 1400 entries at the moment which I copy and paste from notepad/excel.

I am wondering if there is a better way then what I am doing right now... and hope this is in the right forum topic placement, if not please let me know where to add this.

So my function script is as follow:

CODE

<script>
function myFunction() {
  // Declare variables
    var input, filter, ul, li, a, i, txtValue;
  input = document.getElementById('myInput');
  filter = input.value.toUpperCase();
  ul = document.getElementById("myUL");
  li = ul.getElementsByTagName('li');

  // Loop through all list items, and hide those who don't match the search query
  for (i = 0; i < li.length; i++) {
    a = li[i].getElementsByTagName("a")[0];
      txtValue = a.textContent || a.innerText;
    if (txtValue.toUpperCase().indexOf(filter) > -1) {
      li[i].style.display = "";
    } else {
      li[i].style.display = "none";
    }
  }
}
</script>


Then I have my input within the body:
CODE

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for title..">

<ul id="myUL">

"Entries"

</ul>


Anything that I add in the "Entries" section, Example:

CODE
<li class="invalid nav-item"><a href="location.html">Title</a></li>


will appear when I insert something in the search bar (Filter), I do have lots of entries... like I said over 1400 and climbing. What I am looking for is a way that I could only change, well replace the entier list with the new one.

I am working with excel which I keep my lists, then I copy and paste this list to a notepad, to tidy up the space that excel creates, then I replace the entire list by selecting the full list, deleting it and pasting the new one.

Is there a better way to make this happen? Like a way to reference the list that is in between <ul id="myUL"> and </ul>. Right now I am using to many method just to transfer the data... Also using notepad++ to make these changes.

Any help is appreciated smile.gif

Thank you.



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jun 3 2020, 02:40 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



If you create the master list as a text file instead of Excel you can easily include it in the web page with PHP (you may also include the content of Excel files with PHP, but that might be a little more complicated).

BTW the search script you use seems unnecessary, instead you can use your browser's own Find in page feature (Ctrl+F).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Dohm
post Jun 4 2020, 10:00 AM
Post #3





Group: Members
Posts: 6
Joined: 3-June 20
Member No.: 27,374



Just installed php on the server so I will read up on this.

Yes I know about ctrl F the reason is... Well it looks good when you have some sort of search/filter within the page itself.

And the one's that are not computer savvy, well better for them when they need to make a page search. Plus make this to work on all platform, even on Smart TV which some don't have a keyboard.

Thank you.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Dohm
post Jun 4 2020, 10:03 AM
Post #4





Group: Members
Posts: 6
Joined: 3-June 20
Member No.: 27,374



Plus I am making a picture link search...so when one would search for a title, it will bring that specific picture as filter.

This post has been edited by Dohm: Jun 4 2020, 10:04 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:10 AM