简体   繁体   English

一次限制显示12张图像,并自动创建10000张图像的页面

[英]limit 12 images displying at a time and automatically create pages for the 10000 rest

I am try to get 12 images to diplay at a time instead of displaying the 10,000. 我尝试一次显示12张图像,而不显示10,000张。 Someone has told me what to do but Im not sure how to do it. 有人告诉我该怎么做,但我不确定该怎么做。

This is what they said to do: 他们说要这样做:

  • xmlDoc.getElementsByTagName("video"); xmlDoc.getElementsByTagName(“ video”); length of this array will give you total number of page, say length is x so total number of page is x/12 该数组的长度将为您提供总页数,例如长度为x,因此总页数为x / 12
  • You can now create list of page numbers ( 1,2,....n). 您现在可以创建页码列表(1,2,.... n)。 You can use LI tag or other to dynamically create the list using javascript for loop. 您可以使用LI标签或其他标签使用javascript for循环动态创建列表。 In the li put anchor tag for further js page change operation. 在li中放置锚标记以用于进一步的js页面更改操作。
  • Now create an object array inside the for loop. 现在在for循环内创建一个对象数组。
  • For first page take first 12 element and create 12 rows 对于第一页,采用前12个元素并创建12行
  • when page 2 or other is clicked you have to take the page number ( that you can get from the link text) and you have to calculate array index. 当单击第二页或其他页面时,您必须获取页码(可以从链接文本中获取),并且必须计算数组索引。 ( remember for page 2 start index will be 12 and end index will be 23 and so on ) Now clear the existing rows and add the new elements. (请记住,第2页的开始索引将为12,结束索引将为23,依此类推)现在清除现有行并添加新元素。 in short pageSize*( pageNum -1 ) ; 以short pageSize *(pageNum -1);
  • for table creation you can use any template engine (like Handlebar or other) 对于表创建,您可以使用任何模板引擎(例如Handlebar或其他)

This is where he said to do it 他说是在这里做的

<div id="container">
<table id="demo"></table>
    <script>

// Initialize
(function() { 
    loadXMLDoc(); 
})(); 

function loadXMLDoc() {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      myFunction(xmlhttp);
    }
  };
  xmlhttp.open("GET", "amateur.xml", true);
  xmlhttp.send();
}
function myFunction(xml) {
  var i;
  var xmlDoc = xml.responseXML;
  var table="<tr></tr>";
  var x = xmlDoc.getElementsByTagName("video");
  for (i = 0; i <x.length; i++) { 
    var img = x[i].getElementsByTagName("thumbnail")[0].childNodes[0].nodeValue;
    var url = x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue;
    table += 
      "<a href='"+url+"'><img src='"+img+"'></a>";      
  }
  document.getElementById("demo").innerHTML = table;
}
</script>

It looks like a homework, hints: 它看起来像是一项作业,提示:

  • Create a json array on your loop {"url":url, "img":img}; 在循环{“ url”:url,“ img”:img};上创建一个json数组;
  • Populate the table with the first 12 entries, store the current page index. 用前12个条目填充表,存储当前页面索引。
  • Create a navigation bar << < # > >>. 创建导航栏<< <#> >>。 < move previous, << move first, # current page index, > move next, >> move last. <向前移动,<<向后移动,#当前页索引,>向后移动,>>向后移动。

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何限制从xml文件显示的12张图像并自动为其他图像创建页面 - how to limit 12 images displaying from xml file and automatically creating pages for the others 如何上传多张图片,但将其限制为12张(通过智能手机) - How to upload multiple images but limit them to 12 (via smartphone) AngularJS-在一定时间限制后在页面之间切换 - AngularJS-Switching between Pages after Certain Time Limit 在 Firebase 中自动创建新页面 托管用户事件(JAVASCRIPT) - Automatically Create New Pages in Firebase Hosting on user events(JAVASCRIPT) 你如何在 JavaScript 中创建 12 小时的时间 - How do you create a 12hour time in JavaScript 如何将类应用于在运行时通过js自动生成的图像 - How to apply classes to images that are automatically generated at run time through js 如何自动以HTML或Javascript创建图像? - How do I automatically create images in HTML or Javascript? 显示上午1点至上午12点的脚本1,其余时间显示脚本2 - Show script 1 from 6am to 12am and the rest of the time script 2 动态创建/限制随机时间范围并转换为时间戳 - Dynamically create/limit range for random time and convert to timestamp 液位计时器-如何在Unity中创建时间限制? - Level Timer- How to Create Time Limit in Unity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM