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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.