Get input of value and set it to another ID

I need to get the value of a <input id="linkforimg"> and set it to a <font id="imglink"> tag

document.getElementById("imglink").innerHTML = document.getElementById("linkforimg").value;

Why isn’t my code working?

Quick note, the <font id="imglink"> is set to “undefined” instead of the <input id="linkforimg"> value.

Could you please clarify? Did you add the type=“text” attribute?

Yup, i did.

Actually, i didn’t set it to anything, it just shows up as a text input.

Try this

document.getElementById("imglink").textContent = document.getElementById("linkforimg").value;

Ok! I’ll see if it works

Ok, it doesn’t work, the <font id="imglink" is just blank.

Actually wait, what does your HTML look like?

See yourself:

Move <script src="/script.js" defer></script> below the inputs.

No, the other scripts work. It’s just this part that doesn’t work!

Tough lemme try

Ok, still not working.

try my remix:

but if you plan to use this CSS gen for some actual thing don’t

it works, what went wrong?

the ID attribute. It would work if you wanted to select their children instead of the actual element.

1 Like

Ok, thanks! I’ll be marking this as resolved now.

Btw, what’s wrong with it? I am going to use it.
And I am still trying to improve it.

It would take way to much effort and time to make the functions add more attributes, and css placement does matter. Also you have switching elements which you need much more types and switching types every time

1 Like

That’s totally alright.

Tough i am still going to use it since i am too lazy to make my own scripts.

Well good luck taking months instead of taking a few hours coding. Remember, coding is just sitting and typing a lot.

1 Like