Jump to content

finding id on page


rpjd

Recommended Posts

User submits 1 or more refrerences via a form.  On the action page I want to check if any id's on the page match any values submitted in $_POST.

$Ref = $_POST['Ref'];
$source = file_get_contents( 'E:/wamp/www/Project/File.php' );
$document = new DOMDocument;
$document->validateOnParse = true;
$document->LoadHTML($source);
for($i=0; $i<count($Ref); $i++)
{
$ID = $document->getElementById('$Ref[$i]');
}

I have a table on the source page with the same id as a reference contained in $Ref, but getElementById is not seeing/recognsing it.  No idea why not.

 

 

Link to comment
https://forums.phpfreaks.com/topic/234866-finding-id-on-page/
Share on other sites

As I just eluded to, if a reference is submitted via the form ($_POST['Ref']) for the first time, then no table exists with that id(value) and a table is created with that id(value).  If a reference has been previously submitted, the table does exist and a new row is appended to that table.  What I'm trying to do is parse the html on the page and compare the existing table id's if any with submitted references, then call appropriate javascript to create and append the table/row, depending on the comparison result(s).

Link to comment
https://forums.phpfreaks.com/topic/234866-finding-id-on-page/#findComment-1207027
Share on other sites

Just for curiousity sakes, I did file_get_contents() on the file, the file_get_html() on the contents. 

$source = file_get_contents( 'E:/wamp/www/Project/File.php' );
$document = new DOMDocument;
$document->validateOnParse = true; 
$document->file_get_html($source);

Fatal error: Call to undefined method DOMDocument::file_get_html()

Link to comment
https://forums.phpfreaks.com/topic/234866-finding-id-on-page/#findComment-1207230
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.