John Davidson

php - 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?

0 comments
Message:


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.



My Answer:
PHP is a popular server-side scripting language that is used to create dynamic web pages. It is often used in conjunction with HTML to add functionality to websites, such as processing form data, interacting with databases, and generating dynamic content. PHP stands for Hypertext Preprocessor, and it is open-source and widely supported, making it a versatile and powerful tool for web development.

Rate this post

3 of 5 based on 4546 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us