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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.