Forum Moderators: open
I also have an okey button, this is made in php and mysql, I need this button to be able to keep track of which one is the top and bottom on in.
The way I've tried it is by making 4 <p> tags and in my onClick javascript changing the visibility on the tags. This does not seem to be working, nor do I know how I could make php to keep track of it meantime. Thats why I posted in Ajax because I've heard Ajax might be of assistance here. Another problem I seem to have is my safari browser does not react to my onClick on the image, works well in Opera but Safari only reacts on MouseOver.
Example
A
to
B
swap to
B
to
A
I saved this on my desktop and it worked fine in Firefox
<img width="10" height="10" onclick="if(document.getElementById('changethis').innerHTML == 'A') document.getElementById('changethis').innerHTML = 'B'; else document.getElementById('changethis').innerHTML = 'A';" /><p id="changethis">A</p>
If you wanted to send A/B to PHP/MySQL, you could use the javascript document.getElementById.innerHTML via AJAX.
IF you don't already have a working AJAX script, they are readily available with a quick search.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line please -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
</head>
<body>
<form action="" onSubmit="return swap('changeme');">
<input type="submit" value="Click to Change">
<p id="changeme">A</p>
</form>
<script type="text/javascript">
function swap(el) {
if (document.getElementById(el)) {
var obj = document.getElementById(el);
obj.innerHTML=(obj.innerHTML=='A')?'B':'A';
}
return false;
}
</script>
</body>
</html>