Jump to content

Changing img src onmousedown


mattichu

Recommended Posts

Hi!

 

 

Im using the following code to change an image from a tick to a cross:

<script type="text/javascript">
imgs=Array("/new4/images/allow.png","/new4/images/deny.png");
var x=0;

function change() {
document.getElementById("bob").src=imgs[++x];

if (x==1) {
x=-1;
}
}
</script>

<img id="bob" height="20" width="20"src="/new4/images/allow.png" onmousedown="change()">

How would I go about storing the option the user has left it on in an SQL database?

 

any help much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/278786-changing-img-src-onmousedown/
Share on other sites

You would have to send it to a script on the server, probably using AJAX. If it has something to do with a form that will be POSTed, then you can put a hidden field on the form and assign it a value indicating checked or unchecked; then process it with the rest of the form when POSTed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.