Click to See Complete Forum and Search --> : Accessing HTML DOM in PHP


nauman73
09-04-2003, 05:05 AM
Hi!

Can I access HTML DOM in PHP? In JavaScript I know how to do this. For example

var div=document.all.item('myDiv');

gives me a reference to a DIV in my HTML with the id 'myDiv'.

And

div.innerHTML = "";

removes everything from this div.

Just wondering if I can do something similar in PHP. Will appreciate any help.

Nauman

PunkSktBrdr01
09-04-2003, 10:14 PM
Because PHP is a server-side language, it cannot access the DOM. The actual PHP code does not show up in the visitor's browser, only HTML.

pyro
09-04-2003, 10:43 PM
Originally posted by nauman73
var div=document.all.item('myDiv');
That is IE only. Take a look at document.getElementById() (http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-getElBId) for the valid DOM way to reference elements.