[SOLVED] Js syntax please: two values in the same span

Hi guys,
please, how can i add ‘password’ to ‘username’ in
document.getElementById(“u_name”).innerText = ${currentUser.get('username')}

i try to show them in the same field.

Thank you

You can’t show the user’s current password (it is hashed in the server database) if that’s what you’re trying to do.

Otherwise you can just add another value at the end:

document.getElementById("u_name").innerText = `${currentUser.get('username')} test`
1 Like

Thank you,
opps forget about the password, it was a mistake from me to give it as example…i was tired yesterday :slight_smile:

i try to show the ‘username’+ @ + ‘zone’ in the same span

to show this in final

[email protected]

document.getElementById(“u_name”).innerText = ${currentUser.get('username')}

Thank you again

Then you can do

document.getElementById("u_name").innerText = `${currentUser.get('username')}@zone`

Or so it’s a bit clearer

document.getElementById("u_name").innerText = currentUser.get('username') + "@zone"
1 Like

Thank you Glad :slight_smile:

sorry to not been clear in my question. ‘zonenumber’ is a value too . only @ is a text .

my problem is how to show the two values in the same html line
[email protected]

[email protected]

is this correct this way?

document.getElementById("userID").innerText = currentUser.get('username') + "@" ('zone') 

Thank you Glad

Then you just add that variable to the end - it’s not any different from your use of currentUser.get('username').

document.getElementById("u_name").innerText = currentUser.get('username') + "@" + zonenumbervariable
1 Like

is it correct this way?

document.getElementById("userID").innerText = currentUser.get('username') + "@" + ('zone') 

‘zonenumber’ is a value too . only @ is a text .

What you posted will just do text like @. If zonenumber is a variable (that has a value), then use that last example I posted.

I suggest reading this tutorial.

1 Like

thank you Glad.
this is for a registration form.


after login in . i try to show the [email protected] in dashboard

i made it by making
tow lines of code
one for username

document.getElementById("u_name").innerText = currentUser.get('username')  

and one for the zonenumber

document.getElementById("z_num").innerText = currentUser.get('zonenumber')  

then put them side by side in html.
but if is it possible to put them in one JS line it will be fine

document.getElementById("userID").innerText = currentUser.get('username') + "@" +....

Thanks again

document.getElementById("userID").innerText = currentUser.get('username') + "@" + currentUser.get('zonenumber')
1 Like

oh Thank you Glad!! :slight_smile: this is what i try to do.

see you Mage