Changing the HTML name of an object

I am pretty sure the answer is no, but is there any way to change the HTML name of an object?

I have done it by editing the HTML files int he back end but I really wish there was a way to do this in the GUI.

There are times that I may copy an object from another course that may have a JavaScript call or an HTML code happening, and instead of just changing the HTML name of an object, I have to go and change all of the code to match the new random generated name.

Discussion (17)

For most objects, you can rename the HTML name by going to the objects Properties and from the Image group selecting the arrow in the bottom right-hand corner. This opens an expanded description of the object where you can add a long description for 508 or update the HTML name.

HTML-Name.png

@sirwise23 I assign the html names to variables in my external JavaScript files so that I don't have to remember the cumbersome names Lectora generates. For example, when using jQuery, I would do something similar to the following:

var game = $('#image1972'); //Store game image element ID

Instead of addressing objects by their HTML names (which are random and cannot be set by you) in your code, you should address them by class name (which can be assigned by you to any object in Lectora). Then your JS objects will always be reusable.

It's just wishful thinking :) Everybody wants to be able to edit HTML names!!! :D

That's strange. I'm running v16 but yes I can. Let me try with 12.

description.png

You can re-assign the numeral part of the HTML Name (id) but not the characters. If you write your external code accordingly, this could give you the control you are looking for.

1. Add the object(s) you want to rename to your project but do not add actions to them yet.

2. Make a note of the HTML name that was automatically assigned.

3. Save the project and close Lecotra.

4. Open the .awt in a text editor (notepad works fine - use open with..).

5. Find the line that assigns the ID, example

6. Change the number in the parentheses (Here I changed "49" to "995".)

7. Save the file and re-open in Lectora. Your object now has the name you assigned.

You can do this any time you add an object as long as you have not used it in any actions.

Darrel

Hi Jenni,

have you ever been able to actually change the html name of an object? Lectora won't let me edit the field... and it still won't let me select the html name with the keyboard / tab key.

Tim

I uploaded the same image and checked. Confirmed, I can do it from 12.1.4. You might want to open a support ticket and see if something's disconnected on your back end.

12.1.4.png

Lectora 16.0.2 - I can select and copy HTML name of object but I cannot edit the names. I don't think I ever could. Jenny, can you please upload a screenshot of editing the name? E.g. before and after, in the same title, same object?

Esp. if you want to use Renotas approach it may be possible to use the token replacement Math describes here:

http://community.trivantis.com/forums/topic/javascript-and-htmlnames/

It can be done by running the code in a Run javascript action added to the game image

On: Page show

Action: Run javascript

Javascript:

var game = $(undefined

During Publication Lectora will replace %HTMLNAME% with the html name / the id of the object the action is added to.

Tim

I don't know why I had it stuck in my head that I could edit it! LOL I cannot edit the field. The Lectora Information Center says "The HTML name is assigned when you add the object. The HTML name, which is used to identify the object, cannot be changed." I think it's time for some more coffee this morning.....

Did you read my post?

In Lectora itself you cannot edit ( maybe change parts like Darrel suggest..didnot check that ) the html names....

however if needed...

You can open the .awt in any text-editor that supports xml.... find the html-names you want to change...and name them exactly as you want.

My setup for creating Lectora .awt from a .PSD does exactly that...create a Lectora .awt with custom html names.

Apparently not good enough, cause now noticing its the same method ;-) Stupid me :-)

In Fact you can even do this when actions are assigned, but you have to find the proper action and retarget that to your newly created htmlname

Thanks, the opening of an AWT file in a text editor should work well. I will give it a shot. Mostly I have only needed to do this with videos. I tend to use actions on a button to make a video skip to a certain time in the video.

I'm not Darrel, but completing the training is not adding an action, and 508 would not require you to change a button's name in any case. Maybe it's alt-text?

Darrel,

Is there a way to change the HTML name for a button after adding an action? Your instructions are before adding an action, but 508 needs me to add the button HTML name after I completed the training.

Discussions have been disabled for this post