0

I have a page with a basic form (only 1 input) and want to autofocus on that field. When the page loads it is not focused, but if I hit f5 to refresh it will focus. Not sure if this is related, but the form is in a table for css formatting I have applied to the whole website. See below for the code I have used:

if (!isset($_POST['stage'])){
// Starting point, enter lab ref

echo"<form action='recieveasample.php' method='POST'>
<table><tr><td> 
Enter Lab Ref </td><td> 
<input name='labref' autofocus='autofocus' required='required'></input> </td></tr>
<tr><td colspan='2'> <input type='submit' value='NEXT'></input> </td></tr></table>
<input type='hidden' name='stage' value='labref'></input>
</form>";

}elseif(....next step...
Tunna182
  • 343
  • 3
  • 16

2 Answers2

0

The code is working for me. I tried to run you code online here: http://www.runphponline.com/ and the input field gets focus.

pix1289
  • 514
  • 1
  • 7
  • 24
  • Thanks for that :) I just tried that link with my code and it still didn't work, but you got me thinking about why it worked for you and not for me... Maybe we are using different browsers? so I tried a new browser and it's working now :) – Tunna182 Jun 05 '16 at 07:57
  • That's great! :) I tried the link in different browsers and it seems to work only in chrome! – pix1289 Jun 05 '16 at 08:45
0

It's a browser related issue. IE is bad. Firefox is good :)

Tunna182
  • 343
  • 3
  • 16