Wifi push for on release for off switch

Hey guys im just learning arduino coding and im really stuck when it comes to a switch that im using via web browser.

They way its setup now you need to click once for on and click again to turn it off.

I need the switch to turn on when you push it and off when you release. Ive been searching for 2 days for the answer now so thought i would come here and see if i could get som help! Thanks in advance guys!

Ive added a copy of the files ive been following and trying to edit

WiFi-Relay-Controller-master.zip (1.39 MB)

Perhaps you seek a switch of the momentary contact variety.

My understanding is that that switch is a button in the web browser. If so, I think that you will need to look at ajax.

Basically the script needs to do the following:
Detect when the mouse goes down (mousedown); send command to switch relay on.
Detect when mouse goes up (mouseup); send command to switch relay off.

Just in case: W3Schools AJAX Introduction to get you started.

sterretje:
My understanding is that that switch is a button in the web browser. If so, I think that you will need to look at ajax.

Basically the script needs to do the following:
Detect when the mouse goes down (mousedown); send command to switch relay on.
Detect when mouse goes up (mouseup); send command to switch relay off.

Just in case: W3Schools AJAX Introduction to get you started.

I have set this code, but, whenever i add both actions it will only choose one and not the other (ie. Mousedown will work and mouseup wont)

Any ideas why?