Reputation: 6638
I have the following in javascript:
var entriesString = '';
$$('select[id=shopId]').each(function(elem, i){
shops[i] = elem.value;
entries[i] = new Array();
$$('input[id=entry'+i+']').each(function(elem, c){
if(elem.value != '') entries[i][c] = elem.value.replace(".", "").replace(",", "."); else entries[i][c] = '0.0'
});
entriesString += '&entry'+i+'=' + entries[i];
});
Now I'm new to JS and therefore do not know what the first $$('select[id=shopId]')
part means.
It must be some sort of array or collection, due to the .each
part it is followed by.
In that loop is again a nested loop that uses the loop variable i in its head.
But again, I don't know what exactly does %%('input[...]')
mean. What kind of syntax is this?
Also, where does the data.
This is what entryString
looks like for example:
&entry0=65.8,75.5,72.9,67.9,51.1,8.2,47.9&entry1=55.9,33.5,33.8,35.2,26.8,7.0,25.8
Thanks a lot or your help!
Upvotes: 2
Views: 298
Reputation: 11660
your code uses the prototype JS framework. $$('ELEMENTNAME')
instanciates all DOM element with ELEMENTNAME
(so i.e. all input fields) and returns them as array of objects.
with id==xy
it returns that one with id xy
<input type="blah" id="xy" value="123" />
will be found
Upvotes: 2
Reputation: 546243
That looks like the $$
method of the Prototype library. The documentation is here:
http://www.prototypejs.org/api/utility#method-$$
It selects DOM elements given a CSS-style selector.
Upvotes: 5
Reputation: 14783
You are using the Prototype library.
See http://www.prototypejs.org/api/utility/dollar-dollar
Upvotes: 3
Reputation: 18177
$$()
is not something of javascript. It seems to be likely that you're using the Prototype Javascript Framework. Here you find the documentation of $$
: http://api.prototypejs.org/language/dollardollar/
Upvotes: 3