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!
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.
$$()
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/
You are using the Prototype library.
your code uses the prototype JS framework. $$('ELEMENTNAME')
instanciates all DOM element with ELEMENTNAME
(so ie 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
它使用一个很棒的函数来获取带有css选择器的元素。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.