Jump to content

<nextid>


ferren

Recommended Posts

I have 1500 places where <nextid> would be useful. what is the recommended work-around? As is, I have to keep track of numbers. A generic 'next' and 'prev' would be ineffably convenient!

 

Example:

 

<h2 class="cen" id="01"><a class="triangles" href="#00">&vltri; </a>   <a href="#TOP"> BRAIN ANATOMY </a>  &nbs<a class="triangles" href="#02"> &vrtri;</a></h2>

 

<p> ,,,</p>

<h3 id="02"><a class="triangles" href="#01">&vltri; </a>   <a href="#TOP"> 3 Layers of the Brain </a>   <a class="triangles" href="#03"> &vrtri;

 

<p> ,,,</p>

Link to comment
Share on other sites

Are you talking about a workaround for a 20+ year old HTML tag that...

is also probably one of the least understood of all of the early HTML elements, being poorly documented, not explained in any depth anywhere, and those who obviously understood how it worked couldn't be bothered to explain it to the rest of us.

I would suggest using Javascript for something like that. With document.querySelectorAll, for example, it's easy to get a list of elements that match certain selectors, and loop through them. You can also get the element that was clicked on (your next or previous links), and get their next or previous siblings until you find the one you're looking for.
Link to comment
Share on other sites

If you generate these with PHP or Javascrpt it should be easy to keep all the links up to date. The <nextid> element seems to be something completely different and unrelated to what you're asking for.

Link to comment
Share on other sites

@Dave,

 

I hoped the example code would show the usage. Buttons for 'next' and 'prev' are common in paged material; no pages in my html, but I want to jump to adjacent sections. <a href="#id+1">&vrtri;</a> would be ideal. Am I really the only person in 20 years who wants to increment an id number? It seems like such an obvious tool that I hoped someone had figured it out for me. PHP and JavaScript are terra incognita, and a long way from the subject I'm writing about. I am an author, and only reluctantly a programmer.

Link to comment
Share on other sites

No, it wasn't clear to me what you were doing. Are you saying you load a huge, long page and then use links to jump down the page?

 

What is the source of this data? Have you looked at XML and XSLT?

Link to comment
Share on other sites

This is really rough example imagine the arrays here as holding records of data under header, link01 to 03, and then content field names

 

this will loop through arrays retrieving data and applying required id ref as it does so, (also id ref should not begin with number)

 

php page

<!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" />        <title>Document Title</title>        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>        <script  type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>        <script type="text/javascript">        </script>        <style type="text/css">        </style>    </head>    <body>        <?php        $databaseExampleheader = ['h2 class="cen"', 'h3'];        $databaseExamplelink01 = ['&vltri;', '&vltri;']; //this can be removed and added to foreach code        $databaseExamplelink02 = ['BRAIN ANATOMY', '3 Layers of the Brain'];        $databaseExamplelink03 = ['&vrtri;', '&vrtri;']; //this can be removed and added to foreach code        $databaseExampleContent01 = ['<p>                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.            </p>            <p>                Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst.            </p>', '<p>                Fusce convallis, mauris imperdiet gravida bibendum, nisl turpis suscipit mauris, sed placerat ipsum urna sed risus. In convallis tellus a mauris. Curabitur non elit ut libero tristique sodales. Mauris a lacus. Donec mattis semper leo. In hac habitasse platea dictumst. Vivamus facilisis diam at odio. Mauris dictum, nisi eget consequat elementum, lacus ligula molestie metus, non feugiat orci magna ac sem. Donec turpis. Donec vitae metus. Morbi tristique neque eu mauris. Quisque gravida ipsum non sapien. Proin turpis lacus, scelerisque vitae, elementum at, lobortis ac, quam. Aliquam dictum eleifend risus. In hac habitasse platea dictumst. Etiam sit amet diam. Suspendisse odio. Suspendisse nunc. In semper bibendum libero.            </p>            <p>                Proin nonummy, lacus eget pulvinar lacinia, pede felis dignissim leo, vitae tristique magna lacus sit amet eros. Nullam ornare. Praesent odio ligula, dapibus sed, tincidunt eget, dictum ac, nibh. Nam quis lacus. Nunc eleifend molestie velit. Morbi lobortis quam eu velit. Donec euismod vestibulum massa. Donec non lectus. Aliquam commodo lacus sit amet nulla. Cras dignissim elit et augue. Nullam non diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In hac habitasse platea dictumst. Aenean vestibulum. Sed lobortis elit quis lectus. Nunc sed lacus at augue bibendum dapibus.            </p>'];        $count = 0;//loop through array retrieving each value (separated by ',' within it one at a time          foreach ($databaseExampleContent01 as $content) {            echo '<' . $databaseExampleheader[$count] . ' id="id' . ($count + 1) . '">';            echo '<a  class="triangles" href="#id' . $count . '" >' . $databaseExamplelink01[$count] . '</a>';            echo '   <a  href="#TOP" >' . $databaseExamplelink02[$count] . '</a>   ';            echo '<a  class="triangles" href="#id' . ($count + 2) . '" >' . $databaseExamplelink03[$count] . '</a>';            echo '</h3>';            echo '<div>' . $content . '</div>';            $count++;        }        ?>    </body></html>
Link to comment
Share on other sites

Am I really the only person in 20 years who wants to increment an id number?

Of course not, but you may be the only non-programmer today who expects HTML to do everything. Things have progressed a lot since the days of HTML 2 and the nextid element. Tasks have been separated. Today HTML contains no logic or processing, it is strictly a container to hold content. CSS is now around to control how all of that content gets displayed, and Javascript is for any kind of interactivity or action on the page (other than the cosmetic stuff that CSS can do, like simple animation). Those are all client-side languages that the browser understands. On the server there are languages like PHP that allow different content to be delivered based on other factors. The example above uses PHP to print the content and determine on the fly what all of the IDs need to be. That kind of control doesn't belong in the language that is just for holding content. HTML is a dumb language, there's no logic or processing of any kind, just structure and data. There's a way to do something similar in Javascript also without requiring a server-side language, where clicking on a link would run a function which would find the next or previous element that you're trying to jump to (such as an h3 element, or whatever the rule is), and then scroll that element into view.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...