0

I'm trying to create a page where is would work for both login and sign up at the same with by updating the the src of an iframe.

On the nav bar, I have this:

<li id="change"><a onclick="sign()">Sign up</a></li>

And on the iframe:

<iframe src="loginurl" id="frame"></iframe>

Then on the JavaScript, I have this

<script>
        function sign(){
                document.getElementById("frame").src="signupurl";
                document.getElementById("change").innerHTML="<a onclick="login()">Login</a>";
        }
        function login(){
                document.getElementById("frame").src="loginurl";
                document.getElementById("change").innerHTML="<a onclick="sign()">Sign up</a>";
        }
</script>

Its supposed to change the function it would execute onclick of the sign up link to login() And the src of the iframe and vice versa

1 Answer 1

1

This seems to be a problem of quotes. Try this:

function sign() {
  document.getElementById("frame").src = "signupurl";
  document.getElementById("change").innerHTML = '<a onclick="login()">Login</a>';
}

function login() {
  document.getElementById("frame").src = "loginurl";
  document.getElementById("change").innerHTML = '<a onclick="sign()">Sign up</a>';
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.