# Photo XML gallery + first image random

**URL:** <https://forum.kirupa.com/t/photo-xml-gallery-first-image-random/86329>\
**Category:** flash\
**Created:** [April 12, 2005, 8:46am UTC](https://forum.kirupa.com/t/photo-xml-gallery-first-image-random/86329 "2005-04-12T08:46:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micromedia](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Micromedia](https://forum.kirupa.com/u/Micromedia)\
**Post date:** [April 12, 2005, 8:46am UTC](https://forum.kirupa.com/t/photo-xml-gallery-first-image-random/86329/1 "2005-04-12T08:46:33Z")

</div>

Hi there,

I already managed to customize the photo xml gallery code to a random image gallery. But the **problem** now is that the **first picture** is **not random** choosen.

So instead to initialize p = 0 , I tried this :

p = Math.floor(Math.random() \* total);

But unfortunaly then I get NaN ☹

I just want to get this : onload -\> **first image is a random image** ( for example 5 / 10 ) then when I press next it continues counting to 6/10, /, … when I press previous it countinues counting backward to 4/10, 3/10, …

Anyone can help me out ?
