This is my first time posting so please do help if possible :)
I am making a web page but ran into an issue which u may help solve. There are 3 files:
- home.html--> Main page
- login.html--> Page with a form to be opened in an iframe within home.html
- hh.js--> javascipt file
My ultimate goal is to show the user name with will come instead of Login written on home.html after pressing the submit button on the login.html page.
Just for now I am just trying to change the word Login to anything else instead of the username.
The following is the code for hh.js(javascript file):
function goback(){
alert("yes")
var str = document.getElementById("demo").innerHTML;
var res = str.replace("Login","ppap");
document.getElementById("demo").innerHTML = res;
}
Following is code for home.html file (main page) where login word is present
<a onclick="login()"><span id="demo">Login</span></a>
Following is the full code of the file Login.html:
<html>
<head>
<script language="javascript" src="hh.js">
</script>
</head>
<body bgcolor="#000033">
<br><font color="white">
LOGIN<br>
USERNAME:<input type="text" id="user"><br>
PASSWORD:<input type="password"><br>
<button onclick="goback()">Submit</button>
</body></font>
</html>
Problem-
The function goback() is present in both files to just to test. Both pages have a button (Login.html has submit button && home.html has a random button with same function).
When I click button on login (iframe in home.html), it runs alert with yes but does not change the Login word button when I run the button present in home.html with the same function, alert also come as well the Ling word changes to ppap.
What i think is happing- that the submit button runs but the getelementid search for id name in login.html instead of home.html.
Please if anyone can help me with targeting the getlementbyid to home.html, I would be very grateful but please give a very simple code as teachers in school wont understand the code. Also if there is any other easy possible method to do the same I may also receive those answers too asap like instead of using iframe i use to hide that area until function of login is called and then goback() function is called in the same page..