irm
irm

Reputation: 4331

Populating html list from a file

I have several ul on the homepage of my app. Enclosed in each li I have 6 different variables(section#, id, start, end, img, title)

I'm going to be updating the content of the lists constantly so It would be good if I was to be able to populate the page dynamically from a file with this variables organized in an easier to read/update manner.

Here is one list on my app:

<li data-section="number" 
    id="uLAD-IrB8B0" 
    data-start="20" 
    data-end="40">
    <img src="sample.png"/>
    <div class="title">Some title</div>
</li>

I understand this can be accomplish with php. However, I'm not so sure if this is the best alternative or how to move forward on this direction.

Upvotes: 2

Views: 429

Answers (1)

dkniffin
dkniffin

Reputation: 1383

It depends on where your data is coming from, and how you want to update this data.

If you want to update it from files (or a database), you will probably want an AJAX type of architecture. The way that would work is on your client, you'd have some javascript that makes a query to a php script (possibly sending some data), and receives a response with some new data, then the javascript would write that data into the attributes you have above.

However, if your new data is coming from user input, you could get away with just javascript. So, in this case, you might have a text field (or other input fields) that have an onChange handler, which would update the attributes and content you show above.

If you give some more context, I might be able to give you a better answer.

Edit: I would recommend doing some research on AJAX development. This page looks like a good one http://www.sitepoint.com/build-your-own-ajax-web-apps/

Once you have learned how AJAX works, you'll have a better understanding of the components involved (javascript, php, databases, etc). (ie: you'll know what you don't know) :)

I hope that helps.

Upvotes: 3

Related Questions