set focus within a php form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitey
    New Member
    • Sep 2007
    • 17

    set focus within a php form

    hi,

    if i have a form within a php script which looks something like

    <input type=\"text\" name =\"title\" size=\"5\" maxlength=\"6\" >

    how can i have the cursor automatically flashing in the text box?

    Please be aware that this is within php tags.

    Thanks

    Paul
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Can't be done with php.

    It can, however, be done with javascript.

    Comment

    • whitey
      New Member
      • Sep 2007
      • 17

      #3
      thats such a shame as its a really nice simple little effect.

      could i embed the javascript within the php?

      do you have such a script? :-)

      Comment

      • arunj82
        New Member
        • Mar 2007
        • 15

        #4
        Hi,
        This is the example code. you try it.
        Code:
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <HTML>
        <HEAD>
        <TITLE> New Document </TITLE>
        <META NAME="Generator" CONTENT="EditPlus">
        <META NAME="Author" CONTENT="">
        <META NAME="Keywords" CONTENT="">
        <META NAME="Description" CONTENT="">
        <script>
        		function setFocus()
        		{
        				document.frmtest.title.focus();
        		}
        </script>
        </HEAD>
        <BODY onLoad="setFocus()";>
        <form name="frmtest">
        <?
        	echo "<input type=\"text\" name =\"title\" size=\"5\" maxlength=\"6\">";
        ?>
        </BODY>
        </HTML>

        Comment

        Working...