• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

117
Views
I'm trying to capture some text contents from a HTML file, and populate it to another HTML file using Javascript, but why my codes don't work?

I have two HTML files, and I want to change the content of one HTML file by the content of another one. Here are the code segments:

original.html:

<p id="old_1">this is old data</p>

new.html:

<textarea id="new_1" rows="8" cols="80"  style="width:100% !important;"></textarea>
<input type="button" onclick="popData()" id="button_1" value="Send" style="width:100% !important;"/>

I also have a separate js file with function:

function popData()
{
var newContent=document.getElementById("new_1").value;
document.getElementById("old_1").innerHTML=newContent;
}

When I write some thing in the text area, and click the button, the function popData() is called, but when I come back to the original.html, nothing has been changed. Do I need to use PHP? Is it possible to implement it with Javascript and HTML only? And no Iframe.

9 months ago · Juan Pablo Isaza
1 answers
Answer question

0

As these are two separate html files, there is no means of data flow between them.

document.getElementById("new_1").value should work fine if both textarea and <p> tag is on a single html file.

9 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.