Jump to content

Set Focus on Element


chordsoflife

Recommended Posts

I need to set the focus on a particular element without added anything to the body or the head. Is there a way to do that? Here is the code I have to work with:

 

echo "<br /><center><a href='add_concert.php'>Add Another</a></center><br />\n";

 

I just want to be able to press enter on page load.

Link to comment
https://forums.phpfreaks.com/topic/129017-set-focus-on-element/
Share on other sites

you can add an onload() event to the actual body tag; that way it meets your requirements (not in the head or the body - but in the tag instead).

 

<body onload="document.getElementById('focal_link').focus()">

echo "<br /><center><a id='focal_link' href='add_concert.php'>Add Another</a></center><br />\n";

Link to comment
https://forums.phpfreaks.com/topic/129017-set-focus-on-element/#findComment-670604
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.