1
My problem is the following: I have generated a point I made in CSS in an image I call in my JS, however, it should be generated in the coordinates that are captured when clicking on the image.
<script type="text/javascript">
function coordenadas(event){
x = event.clientX;
y = event.clientY;
//alert("X: "+x+" Y: "+y);
}
</script>
<script type="text/javascript">
function image() {
var x = Math.floor(Math.random() * (17 - 1) + 1);
var img = new Image();
img.src = "../radiografias/"+x+".jpg";
document.getElementById('image').innerHTML = "<img style=\"cursor:crosshair\" href=\"#\" onmousedown= \"coordenadas(event)\" src=\""
+ img.src + "\" width=1100 />";
}
</script>
<style>
.ponto{
width: 5px;
height: 5px;
border-radius: 50%;
background-color: #FFFF00;
position: absolute;
}
</style>
<div id="image"></div>
If anyone can help, I’d really appreciate it...
Show man, thank you so much. However, I do not know why he is not creating the point where I click, he ends up creating the point at a distance. Like, running the code here, it actually works, but when I run it on my page, it gives this "error".
– Abel Galvão
I think the error is because I’m getting the coordinates of the screen and not the image itself...
– Abel Galvão
And I’m working with a PHP page
– Abel Galvão
I think the solution to this is to capture the coordinates of my div where my image is, but I still don’t know how to do this.
– Abel Galvão
You can see my full code here: https://github.com/argalvao/Projeto_Odonto
– Abel Galvão
Here you are: https://drive.google.com/file/d/13_BleNp5J_VEuDQb72u9oCfSw3MgzzL7/view?usp=sharing
– Abel Galvão
Sorry it took me so long to answer...
– Abel Galvão
You were able to analyze the code?
– Abel Galvão
Do you have any idea how to make it work?
– Abel Galvão
yeah, I see...
– Abel Galvão
Old...thank you very much. Really worked. You helped me a lot!!
– Abel Galvão
Quiet!.....
– Sam