0

I have a form input that I am using for a list in dashcode. I'm trying to specify a specific item from my list so I can use the code below, but I don't know how.

function fadeout(event)
{
// Values you provide
var itemToFadeOut = document.getElementById("text2");   // replace with name of element to fade

// Fading code
var fadeHandler = function(a, c, s, f){ itemToFadeOut.style.opacity = c; };
new AppleAnimator(8500, 13, 1.0, 0.0, fadeHandler).start();}

When I run this it says the itemToFadeOut is null which I understand because the element doesn't have an Id, it is just a class. How do I a specific element from my dynamic list an id?

Davis Gossage
  • 39
  • 1
  • 4

2 Answers2

0

You don't provide any details of the list or how you expect to access it, so advice can only be general.

You can get a reference to a form control if you can get to the form and the control has a name. If the name is a valid identifier:

var control = form.elements.elementName;

or

var control = form.elementName;

Otherwise you can use:

var control = form.elements[elementName];

or

var control = form[elementName];

If you have more than one with the same name, you can use a numeric index:

var control = form[elementName][index];

or

var control = form.elements[elementName][index];

Or if you just know which one it is, you can get it by index:

var control = form.elements[index];

or

var control = form[index];

If you want to give an element an id (or change its current ID), just assign a value:

element.id = 'whatever';

Does any of that help?

RobG
  • 142,382
  • 31
  • 172
  • 209
0

You can target a specific row element with the following syntax:

rows[i].object.templateElements.<NAME_OF_THE_ELEMENTS_CLASS>.style

where is the name that you gave it in the Dashcode GUI (but leave the _template appendix away) and i is the index of the specific row (you get the index in the prepareRows Function).

Example:

rows[0].object.templateElements.text1.style

where the automatic generated css classname for text1 is text1_template.

Hope it helps.