There are many ways to approach this as far as getting the pagination links to also trigger the population of the hiden form field with the shown image's value. One way is this:
1) Inside virtualpagination.js, add to the very bottom the following:
Code:
// -------------------------------------------------------------------
// Public: sethiddenfield(name, values)- Sets a hidden form field with the designated id to a list of values (array)
// -------------------------------------------------------------------
virtualpaginate.prototype.sethiddenfield=function(fieldname, fieldvalues){
this.hiddenfield=document.getElementById(fieldname)
this.fieldvalues=fieldvalues
}
Then find the following line, and add to it the part in red:
Code:
this.currentpage=parseInt(pagenumber)
if (typeof this.fieldvalues!="undefined")
this.hiddenfield.value=this.fieldvalues[this.currentpage]
2) Then, on your HTML page when invoking a virtual page instance, call the new sethiddenfield() method like so:
Code:
<script type="text/javascript">
var gallery=new virtualpaginate("virtualpage", 1)
gallery.sethiddenfield("test", ["dog.gif", "cat.gif", "monkey.gif", "4.gif"])
gallery.buildpagination("gallerypaginate")
</script>
Where "test" should correspond to the ID of the master hidden form field you wish to populate, and "dog.gif", "cat.gif" etc being the list of image values you wish to populate based on the page number. In other words, "dog.gif" is the image presumed to be on page 1 and so on.
Bookmarks