Jump to content
Emerogork

Can I set the ID of a tag programatically?

Recommended Posts

This is a very difficult question to explain. Other approaches will be considered.

 

If I posted the code/program, you would find it useless believe it or not. If you believe not then I will post it on your request and prove my point. (: The program I am using accepts code through a template and therefore is not, in itself executable code. The user calls for templates as needed. To see this in action, you would need a server with Moodle (Linux, Apache, PHP5, etc) running and have the Generico Filters plugin installed. If you do, and you understand the program, then I could send you the .txt file.

 

Ok, so this has to be solved theoretically instead of practically.

 

Here is the line of code that I can use to send the date called stopdate2a as an ID in a span used in the HTML program.

 

(JS) document.getElementById("StartDA").innerHTML = stopdate2A;

(HTML) <p>@@Message@@<span id="StartDA"> Stop Date </span></p>

 

“Stop Date” gets replaced by the date in stopdate2a.

It works fine if I am using only one template.

 

The Javascript functions and the HTML page get called for each template and the StartDA span ID is in many separate instances of HTML therefore the use of <span id=StartDA></span> can be used. The problem is that the function in JS generates a new value of StartDA and each instance is to be used in a different location. At the moment, StartDA appears the same value everywhere. The problem is that it is to be unique.

 

Since I presently need 25 templates I need to be able to identify each instance of StartDA. If I could send "StartDA" as a variable instead of text, I could use something like an array such as StartDA(X) and increment X as needed.

 

I am sure that if I used document.getElementByclass("StartDA").innerHTML = stopdate2A; that I would have the same problem.

 

I will leave it there for now to see if anyone can make any sense out of all this and see what questions/remedies are proposed.

 

 

Share this post


Link to post
Share on other sites

The length of That your script will not stop you from posting them, You need to post them or upload it online so we can take a closer look on it. Also, you need to be specific. Always go step-by-step while creating a code. Be sure of what a code does before even trying to copy them. Because a code you wrote by yourself will never be complicated. That so called "copy and start using" that is where you will encounter problem.

Edited by Chikwado

Share this post


Link to post
Share on other sites

If you give them a class identifier, you could loop through them to give each a unique id depending on that class index, or maybe a 'data-' custom attribute value instead.

Share this post


Link to post
Share on other sites

I believe the .position.Set one is part of the b2BodyDef class? That is what you use when first defining the body to create it. Its not really necessary since you can do the .SetPosition on the body after its created.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...