I have to set price to be focused when the page using onload.
<body style="border: solid 1px black; margin-left: auto;margin-right: auto;width: 500px;">
<form>
<fieldset style="margin:25px";><legend>Discount Calculator</legend>
<div style="text-align: right; margin-right: 25%;">
<label>Enter Price: <input onload = "thing()" type="text" name="price" id="price"></label><br><br>
</div>
</fieldset>
</form>
<script type="text/javascript">
function thing()
{
document.focus()
}
</script>
</body>
I know I am doing something wrong. I can easily set this to be focused by using document.findElementById("price").focus()
, but for this assignment I need to do it as onload. Any help would be appreciated.