Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript Pause after each iteration AND update body?

Michael E

New Coder
This is probably a really stupid question, but I'd greatly appreciate if someone could point me in the right direction. I'm writing a wave function collapse program in JavaScript embedded in HTML. It selects and places graphic tile images. I don't see anything happening until all tiles are placed (there are thousands). I'd like to be able to step through each tile's placement and see the updated page before the next tile is placed. I'm sure I'm missing something super simple here, but my searches online aren't finding anything. Thanks much.
 
My code is irrelevant, but the example below should work. This function assumes I've already loaded all images into the body of the page. I need to know what I need to insert where shown to cause the page to update after each image src is changed by the loop.

Thanks!

function doIt() { for (j = 0; j < 1000; j++) { document.getElementbyId(hex[j]).src = "00-00-00-00-00-00.png"; //NEED SOMETHING HERE THAT ALLOWS ME TO SEE EACH IMG AFTER ITS SOURCE FILE IS CHANGED INSTEAD OF WAITING TILL THE FUNCTION COMPLETES TO SEE THEM ALL CHANGED AT ONCE alert("Pause so I can see the changed img before proceeding to the next step in the loop); } } IN
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom