My webpage allows users to select items from a dropdown list and has a table. Javascript prints out each dropdown-list-item (plus extra info that javascript pulls from the XML file) in a new table row that javascript creates.
I want to be able to write the table information to disk.
If I was using Javascript, I would use document.getElementByID(“table”) to parse through the nodes and put that info into variables that I could write. However, most documentation I find says Javascript is not used for writing to disk. So, I think I should use php.
What is the php equivalent of Javascript’s ‘document’ object?
In Javascript I don’t need to define any new objects to use it, I can use ‘document’ anytime.
I think in php I have to use new DOMDocument. and then load the html.
Most of the php examples show loadHTML(string) and loadHTMLFile();
I don’t want to load HTML from a string that I write inside the tags.
And I don’t want to load HTML from the .htm file because that’s the original file and Javascript has changed the user’s file based on their selections from the dropdown menu.
I want to access the elements of the current document using php.
So, how does php refer to the current document?
The page I’m working on is http://music.collwyncraig.info/hajimama/setlist.htm
I think your thoughts about the architecture are wrong. There is a way how the programming languages interact with each other.
So when u call in your documents javascript functions – the basic php has already done its job.
Instead of printing all generated contents from php directly to the screen, you can store it first in a var.
For example:
so with that you can do the following to print it on the screen:
or
So the contents of your file would be:
This generated document can then be called by
loadHTMLor used in which way youwant.
This just as a hint into which direction you can think – there are quite multiple ways of solution – so without knowing more about what u really want – it is quite not easy to mention a proper solution.