-2
I wonder how I can do for every click I give worth one by one number , type instead of I put an input number next to the checkbox I would like to make each click I give in the checkebox worth for a number.
-2
I wonder how I can do for every click I give worth one by one number , type instead of I put an input number next to the checkbox I would like to make each click I give in the checkebox worth for a number.
2
A very simplistic solution would be something like this:
<!DOCTYPE html>
<html>
<body>
Checkbox: <input type="checkbox" id="m1" value="1" onclick="myFunction('m1')">
Checkbox: <input type="checkbox" id="m2" value="2" onclick="myFunction('m2')">
Checkbox: <input type="checkbox" id="m3" value="3" onclick="myFunction('m3')">
<p>Click the "Try it" button to display the value of the value attribute of the checkbox.</p>
<p id="demo"></p>
<script>
function myFunction(id) {
var x = document.getElementById(id).value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
Browser other questions tagged php html
You are not signed in. Login or sign up in order to post.
Looking at the image and taking it as an example, I assume that you want to associate a number with each checkbox so that when you press Compare, the program knows what to compare with the clicked checkboxes. Correct?
– Rene Freak
your checkbox looks like this: Checkbox: <input type="checkbox" id="myCheck" value="myvalue">. assigns a value for each value
– Israel Zebulon
It’s not that the checkbox side had an input number and I took it out, and I wanted every click I give in the checkbox to be equivalent to a number in the input number @Israelzebulon
– allan araujo
takes this answer code and implements it within myFunction()
– Israel Zebulon
@Israelzebulon put it didn’t work
– allan araujo
add an input to the side and give an id to it.... within the function you use Document.getElementById(id). value; to add or take the value inside the input
– Israel Zebulon