Custom code (get page url in a form) that is in a collection - loads only into first item

Happy to say i could solve this with the help of a friend. I now use the class instead of ID and the script gives me more than just one position.

I put this code in the body tag of the page:

var elements = 
for (var i = 0; i < elements.length; i++) {
elements[i].value = location.pathname;

And this in the hidden Field:

<input type="hidden" class="Key" name="Url" value="" />

That was the initial problem…

Hi everyone,

i try to transmit the page URL via a hidden field. That works, but as you can see, it only works for the first item field, but i need the url in all of them.

Here is the hidden field:

In the live version it loads the url only on one field:/

//At the moment i use this code as suggested by Michael before the body tag of the page:
<script type="text/javascript">
{document.getElementById('pageurl').value = window.location.href;}


//In the HTML embed: 
<input type="hidden" id="pageurl"  name="pageurl" value="pageurl" />

Does anyone have knowledge if that is in general not possible and what the workaround could be?

Thanks your very much!