Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:40:55+00:00 2026-06-12T18:40:55+00:00

I have a comics website which loops through all images in a db and

  • 0

I have a comics website which loops through all images in a db and displays them as thumbnails. The user can click on one of those images to see it in normal size on a viewcomic.php template.

I’d like to allow users to press left and right arrows to navigate images.

In viewcomic.php, I have the following javascript which only runs when I comment out any php.

     //so if I comment out this line, it will run fine 
var imgArray = [<?php echo implode(',', getImages()) ?>];

$(document).ready(function() {
    var img = document.getElementById("theImage");
    alert("run");
    var imgIndex = 0;
    $(document).keydown(function (e) {
        if (e.which == 39) {
            alert("next image");
            img.src = imgArray[imgIndex++]
        }

    });
}); 

In firebug, I’m getting the following error:

invalid regular expression flag a
[Break On This Error]   

Referring to:

 var imgArray = [/images/all_comics/'Number_1.jpg',/images/all_comics/'Number_2.j...

But, Firebug shows that imgArray seems to be properly filled with jscript-readable strings:

 var imgArray = [/images/all_comics/'Number_1.jpg',/images/all_comics/'Number_2.jpg',/images/all_comics/'Number_3.jpg',/images/all_comics/'Number_4.jpg',/images/all_comics/'Number_5.jpg'];

Any ideas would be appreciated!

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:40:55+00:00Added an answer on June 12, 2026 at 6:40 pm

    As the Firebug error states, because your array values are quoted incompletely, it parses them as faulty regular expressions because of the slashes which are regexp delimiters.

    Instead of

    /images/all_comics/'Number_1.jpg'

    you need to quote the whole value as

    '/images/all_comics/Number_1.jpg'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a comics website which loops through all images in a db and
Have deployed numerous report parts which reference the same view however one of them
I have written a Python script to download all of the xkcd comic images.
I'm building a website which will show comics. I'd like to store each image
I have a simple application that views comics and allows the user to mark
I have these 2 queries and i would like to join them into one
Comics object can have many Chapter object. I have this in Comics class: @OneToMany(targetEntity=Chapter.class,
I have a website on which I want to post the current xkcd comic.
Inspired by the XKCD geohashing comic (http://imgs.xkcd.com/comics/geohashing.png), I thought I'd have a go at
have written this little class, which generates a UUID every time an object of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.