EdwardBlack EdwardBlack - 2 months ago 27
PHP Question

Inject GET parameter to target URL of a button, on click

I have multiple buttons with the class

. Each button has a value which is send to a server on click.
The target URL of the button does look like this:


After I click on the button, the follwing GET parameter should be added to the URL and then the button should be submitted:


So the new URL should look like this:


Why I have to inject it?

I am working with
. AFAIK it is not possible to manipulate fluid tags with javascript. However, i urgently need to add a
item value to the fluid tags

My fluid code:

<f:link.action controller="Download" action="download" arguments="{cid: category.uid}" class="myButton">Download</f:link.action>

So my attempt is to append my sessionStorage item as GET parameter to the target URL of the button and then send it, e.g.:

//First prevent the default event

...inject the sessionStorage item as GET parameter to the target URL of the button, then do whatever the button would do normally...

//Go to new URL
window.location.replace(NEW URL);

Is this possible?

EDIT: This is how the rendered HTML of the buttons looks like:

<a class="myButton" href="/de/mysite/test/test.html?tx_mydownloads_myfilelist%5Bcid%5D=15&amp;&amp;tx_mydownloads_myfilelist%5Baction%5D=download&amp;tx_mydownloads_myfilelist%5Bcontroller%5D=Download&amp;cHash=d009eb3f9f4e1020435b96a8f7150ad5">Download</a>

EDIT: I have another idea, maybe i could just read the target URL somehow, then add my new GET param to it and then load that URL with


You can indeed just use the href from the button and use it to feed window.location.href, like so:

$('.myButton').on('click', function(e) {


    var href = $(this).attr('href'),
        queryString = 'mySessionVar='+sessionStorage.getItem("myItem"),

    if (href.indexOf('?') !== -1) {

        newHref = href + '&' + queryString;

    } else {

        newHref = href + '?' + queryString;

    window.location.href = newHref;

This also handles the case when there is no previous query string present on the link and appends it with ? instead of &, but that part can be omitted if that won't happen in your app.