I have it set up so that onclick (on a picure) calls the following function:

function nxtimg(country){
    document.getElementById("imgcont").src="images",country,"/",imgs[i],".jpg";
    i++;
}

When I click on the image however, accorfing to firebug, the src of the image is; "images". It should have been changed to something like:
"images/a/flag".
Where did I mess up?

what are the commas for? plusyou have missed a forward slash on image path. this May work

function nxtimg(country){
  document.getElementById("imgcont").src="images/" + country + "/" + imgs[i] + ".jpg";
  i++;
}

@theHop
When I use plusses the function doesn't do anything...
Why's that?

you've most probably lost refference to your counter (i)

try this

function nxtimg(contry){
    document.getElementById("imgcou").src = \""images/" +country +"/" + imgs[i] + ".jpg"\";
    i++;
}

but i don't realy understand your code. what is the use of imgs[i].
if the onclick is trigered and the code runs. i will be incread and then the code exit. there must be a way of passing the new value of i but into the code. if i know the meaning of imgs[i] i will be able to help you more.

try this

The code doesn't need the \", and there's also a typo in getElementById("img**cou**"). The OP originally used *imgcont*.

To the OP: Are you declaring i outside of the function? Otherwise i loses its value every time you exit the function, so it'll always return the same value, and you'll always get the same image. This is pretty much a more verbose way of saying what Troy III mentioned.

@ EvolutionFallen so the solution is to declear the i outside the function.
by the way thanks for the typo correction

@ EvolutionFallen so the solution is to declear the i outside the function.
by the way thanks for the typo correction

Yup! Otherwise once you exit the function's scope, i is unset.

@EvolutionFallen Yes. I was assuming it already was declared outside the function somewhere. Probably should've mentioned that :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.