SOLVED: How to set the ID or name of an element on the published website?

I generally love that Wix obfuscates the element ID of the published version of the website.

However, I’m trying to create my own custom login form, and I’d like it to allow LastPass to automatically fill it in. But as I understand it, LastPass pretty much requires that either the field IDs or names are things such as “UserID” and “Password”.

Do I need to create custom html elements to make this work… or can I set these attributes somehow for Wix elements? Would be nice to be able to set custom attributes for elements.

You can’t change anything on a published website just so you can get your LastPass app to work with a Wix website instead of you having to type in your email and password.

If you were designing your own website then Wix lets you rename the element id name so that you can use whatever you want for each element id name.

This forum is for issues with code that is used on a Wix website, it is not a forum to help LastPass users try to get their app to work with a published website that was made through Wix.

Your best solution is to go ask LastPass own support pages as it is amazing what you can find there already, like set the URL in the site entry to “users.wix.com” and use the right click menu to autofill.

Thanks givemeWhisky, think you misunderstand… I am designing a website using Wix and Wix code and was hoping to find a way (which I assumed would mean using Wix code…) to change element IDs and names. Just figured giving the specific scenario that applies here would help make explaining it simpler.

I appreciate the response.

The IDs of page elements cannot be changed in code. They can only be changed in the visual Editor. Of course, if you have code that uses an element, and you change the element’s name, you’ll have to also adjust your code.

I did start to reply with a post about changing the elements id names in the properties panel and to make your own custom login and signup lightboxes.

However, then I stopped and replied different as you were talking about a published site and trying to get LastPass to work with it instead.

I can understand the confusion!

Anyways to carry on with Yisrael post above, yes you can only change the element id name in the properties panel from within the Wix Editor.
https://support.wix.com/en/article/corvid-working-with-the-properties-panel

This doesn’t state that you can now also right click on the element to get to the properties panel too if you haven’t got it up on screen already.

Through this properties panel you can also add any event to the element like onClick, onMouse, onViewport and onDblClick which are needed if you haven’t written it through your code.
https://support.wix.com/en/article/corvid-reacting-to-user-actions-using-events

$w("#forgotPassword").onClick( (event) => {
// onClick event is included in the code so no need to click it in properties for element

export function loginButton_click(event) {
// onClick event needs to be clicked on in properties for this element as not included in code.

Also as Yisrael pointed out, if you change your element id name then it needs to be reflected in any code that you write on that page for it too.

Plus, it is always best to change element id names so you can associate it with the function that it is being used for and it is much easier to remember what it is in your code setup too.

Too many time people post on this forum with code that includes a button with a name of button100 or a text box with a name of text200 for example,

Now how can you work with that in your code and trying to remember where and what each 100 buttons do and the same with the 200 text boxes, of which 100+ might not even be used anymore and had been deleted!

Finally, if you need any help with the custom login and signup lightboxes then just post again or ask another question in the forum again.

keep the Wix API reference section bookmarked too as you will need it many a times.
https://www.wix.com/corvid/reference/APIsOverview.html

@givemeawhisky Hey! I always use #button1, #text23, #repeater2, etc. It builds character.

@yisrael-wix Yes I’ve often heard that the older generation don’t like to change their ways of working :wink: Although are you sure it isn’t just the beer building your character…

By the way, I read an old post yesterday with yourself and Andreas (Kviby) chatting about fixing problems whilst drinking beer, beer and more beer, instant laughing happened, now that sounds like a great problem solving session and Wix definitely needs Andreas back somehow.

…Why does everything come back to alcohol :tumbler_glass::grin:

Is there a way to auto increment custom element ids and assign them. I am trying to create a dynamic slide show as per this https://www.wix.com/corvid/example/dynamic-slideshow .

Every time I add a new slide or duplicate a slide from Wix editor, it assigns a random ids. Say on a slide I give a text element id as #iName0, #iName1. If I duplicate a new slide, the text element id becomes as #text245 and not as #iName3.

My problem is that I have add 40 slides and so have to change its element ids one by one so that it fits my code.

Any suggestion?

For #text1 through #text5, something like this will work:

 for(let i = 1; i <=5; i++) {
        $w(`#text${i}`).show();
 }

I would like to follow up on this. What I am looking for is a way to use a link to a certain section of the (one pager) main page like mysite.com#prices that can be shared.

Unfortunately wix give you the ability to change ids of elements in the visual editor, but these seem to be for internal use only, since the published site doesn’t have these ids but rather ids like #comp-kwcbe6lp.

That is not something you want to give your customers to click on.

So. Is there any way to declare public ids?

Seems like you are searching for this one …
https://www.wix.com/velo/reference/$w/anchor

@russian-dima I thought so too, but that - as every other element on the page - does not have a publicly named id, but a computed one once the site is published.


maybe this helps understanding the problem. I want the “calculator” to be the ID of the element, not some label, so I can create a real link to it, not a wix-internal link.

Sorry, but perhaps @J.D. can help you better in this case (i see he is also online at moment).

@russian-dima I found a way by adding a custom element. For these you can define public attributes. That might have been an answer for @matt42150 as well. :woman_shrugging:

But it’s not very comfortable, so maybe this qualifies for a feature request :).

Can you share how you did this? I also would like to add real anchors. I called in last week and they said it wasn’t possible ;).

Hey @syssimplesalt I made you some screenshots. Basically you add “Embed” > “Custom Embeds” > “Custom Element” and then define attributes. These are completely free, so you have to know which html attributes there are, but for programming reasons - who cares what they are called :woman_shrugging:

If you want to link to the element, you add the attribute ID and give it the name you want. You can then “link” to this element by adding it with a # to your url like mysite.com#myanchor.

Have fun!

@katharina55374
Die gezeigte Nummer ist öffentlich zugänglich?

@russian-dima jup

I have a website where I have 32 buttons - 1 for each team. I want to use the NFL team name to determine which button was clicked and decide what to do based on hte clicked id. When I looked in the wix editor (dev mode) I can see that the buttons all have eberic names (button1, button2, button23, etc). How can I change thes names to be the real names of the NFL teams. I want to use a switch and case statement to test the button id and decide which button was clicked and what action to take based on hte clicked button. How do I change the generic names to the real team names?