Getting elements of a div from another page (PHP)
You can use DOMDocument in PHP:
<?php
$doc = new DomDocument;
// We need to validate our document before refering to the id
$doc->validateOnParse = true;
$doc->loadHtml(file_get_contents('http://google.com/bla.php'));
var_dump($doc->getElementById('div1'));
?>
how to pass the id of a div to another php page when it is clicked
Not sure if this will suffice, but you could try this:
<a href="<?php echo 'video_tut.php?vid_id='.$video_id; ?>" title="View post details">
<img width="370" height="193" src="http://img.youtube.com/vi/<?php echo $video_id?>/hqdefault.jpg" class="img-responsive wp-post-image" alt="Teen girl sitting with a laptop" />
</a>
Instead of getting the id
from the div
, I added the id
as a GET query in the href
of the a
element. Then in the video_tut.php
, you can use this to get the id
value:
if(isset($_GET['vid_id'])){
$vidID = $_GET['vid_id'];
}
Here I'm assuming that exposing the $video_id
in the URL does not pose some sort of security risks.
How to pass a div created with javascript to another page with php
You shouldn't have to send the entire div just the amount of data that's required for the next page to recreate it.
i.e. you could use a cookie and have the user remember:
document.cookie = "divinfo=The text field of the div's;\
path=/";
have a hidden input field that contained the relevant information.
<input name="divinfo" hidden value="The info required for the creation of the div"/>
If you use the cookie the javascript could recreate the data on the other side if you use the hidden input you should have the php recreate it.
Change loaded div from another page with another one on the same page
When the ("#innercont1").click
event listener is created, there is no element in the DOM with the id innercont1, since that element is dynamically loaded from elsewhere. What you need for this instance is an event listener that will catch any element with that id at any time. You can bind the listener to the body element instead, like so:
$(document.body).on('click', '#innercont1', function(){
//code
});
how to get all elements of div from another page in web service aspx
Pass it like this
JSON.stringify({'num':HTML});
You have to stringify the content to JSON properly. HTML may contain synataxes that would make
the JSON notation invalid.
var dataToSend = JSON.stringify({'num':HTML});
$.ajax({ url: "EditingTextarea.aspx/GetValue",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: dataToSend , // pass that text to the server as a correct JSON String
success: function (msg) { alert(msg.d); },
error: function (type) { alert("ERROR!!" + type.responseText); }
});
Hyperlink to a div on another page in PHP
You are dealing with named anchors.
In this, you can give link to a particular section in the page.
E.g.
Say, I have following divs.
<div id="first">Bla Bla</div>
And this div is far below header, you can give a link to it using hash.
<a href="#first">Go to First</a>
By clicking on the link, your respective div
will get focused.
Related Topics
Issues Porting PHP/Gd Wrapper to Imagick
Url Encoded Forward Slashes Breaking My Codeigniter App
Simplexmlelement and Xpath, Getting Empty Array()
How to Make a Select in PHP/MySQL Case Insensitive
How to Check If the Request Came from Mobile or Computer in PHP
Set Value of Single Object in Multidimensional Array in Twig Template
PHP Thumbnail Image Resizing with Proportions
File Upload PHP $_Files Undefined Index Error
Insert a Persian Text in MySQL Table
PHP - Upload Picture and Display on Page
Get All Work Days in a Week for a Given Date
How to Use Multiple PHP Header Content Types on the Same Page? Is This Possible
How to Change the Name of an Element in Dom
PHP Making a Download Counter Without Leaving the Current Page
Get a Single Row from the Database Using Ajax in Codeigniter
Php/MySQL Prevent Duplicate Entries Over Multiple Columns