Learn and adapt from the following example:
<!DOCTYPE html>
<html>
<body>
<p>Click to get next image</p>
<image src="/images/P100_01.gif" id="img">
<button type="button" onclick="getNextImage()">Get Image</button>
<script>
function getNextImage() {
var oldImageSource = document.getElementById("img").src;
alert(oldImageSource);
var str = oldImageSource.slice(9,12);
var oldNum = Number(str);
alert(oldNum);
var newNum = oldNum + 1;
alert(newNum);
var newImageSource = oldImageSource.replace(oldNum, newNum);
alert(newImageSource);
}
</script>
</body>
</html>
Read more on
JavaScript String Object[
^]