Reputation: 427
I am trying to move between pages, but when I try to go to the next page it does not work as expected. When I click it the first time the result is 01 instead of 1, and the second time it becomes 011 instead of 2. What am I doing wrong?
HTML:
<p id='page'>0</p>
<div id='pics'>
<a href='<?=URL;?>index.php?p=gallery&image=<?=$pic['album_pic_id'];?>'>
<img class='<?php if($pic['album_pic_id'] == $image)
{ echo "selected_pic"; } ?>' width='90px' height='60px'
src='<?=URL;?>images/albums/<?=$pic['album_pic_photo'];?>' />
</a>
<a onclick='getElementById("page").value = getElementById("page").value+1;'>
Pievienot
</a>
</div>
Javascript:
window.onload = function() {
var page = 0;
};
Upvotes: 1
Views: 168
Reputation: 91359
Use innerHTML
and parse its content to an integer with parseInt
:
<a onclick='getElementById("page").innerHTML = parseInt(getElementById("page").innerHTML) + 1;'>Pievienot</a>
value
only works with form
elements such as input
.
Upvotes: 4