How to bind data of mysql from existing iframe into a new iframe on the same webpage

Joined
Oct 26, 2022
Messages
1
Reaction score
0
Hi

I have perl script in which onclick the column in left panel iframe the data got binded with right panel that works perfect. but how can i now bind data to a new iframe on right side by click on the cloumn of iframe on left side. please let me know i will be thankful to you
 
Joined
Jan 30, 2023
Messages
107
Reaction score
13
To bind data to a new iframe on the right side in your Perl script, you can use JavaScript to handle the click event on the column in the left panel iframe, then use JavaScript to dynamically create the new iframe on the right side and populate it with the data you want to bind to it.

Here's an example code snippet to get you started:

Code:
<iframe id="left-panel-iframe" onclick="bindDataToRightIframe(event)">
  <!-- Left panel iframe content -->
</iframe>

<div id="right-side">
  <!-- Right side content -->
</div>

<script>
  function bindDataToRightIframe(event) {
    // Get the data to bind from the click event
    const data = event.target.innerHTML;

    // Create the new iframe
    const rightIframe = document.createElement("iframe");
    rightIframe.id = "right-panel-iframe";
    rightIframe.srcdoc = data;

    // Append the new iframe to the right side
    document.getElementById("right-side").appendChild(rightIframe);
  }
</script>

Next time share your code
 
Joined
Nov 23, 2023
Messages
59
Reaction score
3
Hi

I have perl script in which onclick the column in left panel iframe the data got binded with right panel that works perfect. but how can i now bind data to a new iframe on right side by click on the cloumn of iframe on left side. please let me know i will be thankful to you

To bind data from MySQL in an existing iframe to a new iframe on the same webpage, you'll typically need to perform some server-side processing to fetch the data from the database and then inject it into the new iframe. Here's a general approach you can follow:

  1. Server-Side Processing: Write server-side code (e.g., PHP, Node.js, Python) to connect to your MySQL database and fetch the data you want to display in the iframe. This code will typically involve executing a database query and retrieving the result set.
  2. Format the Data: Once you have retrieved the data from the database, format it in a way that can be easily injected into the new iframe. This might involve converting the data into JSON format or any other suitable format depending on your requirements.
  3. Inject Data into the New Iframe: Use JavaScript to dynamically create a new iframe element on the webpage, and set its src attribute to a page that will render the data. You can pass the data to the new iframe either as URL parameters or by using JavaScript to populate the iframe's content after it has been created.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,443
Members
47,090
Latest member
LillieRipl

Latest Threads

Top