I have a php page with buttons defined like this:
$id=17;
echo " <a href='#' class='btn btn-xs' onclick=process($id,'99')>ON</a>";
calling a script:
<iframe height='0' width='0' name='hiddenFrame' id='hiddenFrame'>
</iframe>
<script language=javascript>
// Grab the device id and type and append them to the forms querystring ...
function process(id,value)
{
document.getElementById("hiddenFrame").src="http://192.168.1.90/JSON?request=controldevicebyvalue&ref=" + id +"&value=" + value;
}
</script>
The purpose is to call the URL in the script with the parameters as it will trigger an event on the API. The buttons and the scripts works, but I when I hit a button in the buttom of the page, it scrolls to the top - which is quite unwanted with a mobile device where my page will be long. Furthermore, I think the purpose can be achived with less or more elegant code?