Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I replace placeholder text in a rendered HTML page dynamically?
    primarykey
    data
    text
    <p>I wish I could think of a better way to word my question, but basically here is what I want to do: in an HTML file, I would like to fill the body with a specific string multiple times. For example:</p> <pre><code>&lt;div&gt; This is some content. XXX &lt;/div&gt; &lt;div&gt; This is some more content. XXX &lt;/div&gt; &lt;div&gt; This is even more content. XXX &lt;/div&gt; </code></pre> <p>Then, I would like some script to go through the page, and replace every instance of the string (in this case XXX but it could be anything) with an incrementing number, so, like:</p> <pre><code>&lt;div&gt; This is some content. 001 &lt;/div&gt; &lt;div&gt; This is some more content. 002 &lt;/div&gt; &lt;div&gt; This is even more content. 003 &lt;/div&gt; </code></pre> <p>This is a simple example of course, and you might be thinking well that's dumb, just type the numbers. But obviously this is simpler than what I'm intending to do, and right now what I'm building, the order of all the content has not been decided yet, so things could move up or down in their placement on the page, but I'd like all the numbers to be sequential in order of their appearance on the page.</p> <p>So, final thoughts: I am super sure there's a way better way to do this than I'm even thinking of, methodology wise (i.e., make an XML table or something). I am definitely open to ANY suggestion on how to do this, but I am kind of an idiot so if your answer is "pff this would be super easy in Ruby just use Ruby", that's not gonna really get me where I need to be. Also if this has already been answered, it was hard to think of how to word the question to search for previous answers so I apologize in advance if I didn't find the pre-existing answer when I was searching.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload