Rough overview:
I am reading an XML file through XMLhttpRequest and outputting each item into a unique div tag, which has a dynamically generated name, then appending each div tag to an existing div tag. This is working A-OK.
Here's the problem:
Basically so I can show a general section - ie. Bookmarks, Blog Posts, etc - then show or hide specific items within each section. I want to be able to show the next or previous X items through another javascript function, but the number of items can cahnge with each refresh of the page, so to be able to tell how many items are contained within each section's div tags i am creating two hidden form input at the end of writing the items. One is the total number of items in the section, the other value is the starting number of the currently displayed items. I am placing these two values into a form which is created.
here's the code to create the form as well as the inputs
Expand|Select|Wrap|Line Numbers
- // create form
- newHiddenForm = document.createElement("form");
- newHiddenForm.name = newFormName;
- newHiddenForm.id = newFormName;
- document.body.appendChild(newHiddenForm);
- //create input for total
- newHiddenInput1 = document.createElement("input");
- newHiddenInput1.type = "hidden";
- newHiddenInput1.name = totalFormName;
- newHiddenInput1.id = totalFormName;
- newHiddenInput1.value = i; // i is the loop limiter
- // create input for start value
- newHiddenInput2 = document.createElement("input");
- newHiddenInput2.type = "hidden";
- newHiddenInput2.name = startFormName;
- newHiddenInput2.id = startFormName;
- newHiddenInput2.value = 0;
- //append the two inputs to the form
- mainFormElement = document.getElementById(newFormName);
- mainFormElement.appendChild(newHiddenInput1);
- mainFormElement.appendChild(newHiddenInput2);
Expand|Select|Wrap|Line Numbers
- totalObj = document.getElementById(totalName);
- totalItems = totalObj.value
Any suggestions?