I've built a function that rotates a picture when you click a button. I would like to tell this function how many degrees I want it to rotate with a text field or something like that and also call a function that's being executed in php that moves a stepper motor. Is there a way to do so? I've tried with a submit button but it doesn't show the animation the way I want to.
Submit button are generally used to submit forms. Although you can use them too, its not recommend. You can simply use <button />
element. And you can pass the function parameter on the onclick
event handler of the button.
<button id="rotate" onclick= "rotate('35')">Rotate</button>
If you want to get value of text field and send in the form.
<button id="rotate" onclick= "rotate(document.getElementById('textboxid').value)">Rotate</button>
However, calling a function being executed over PHP is a tricky part. There are different ways you can do that:
page.php?function=test