Cursor landing / position

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trochia
    New Member
    • Oct 2008
    • 19

    Cursor landing / position

    Hello, and thank-you for reading this. I have used the the advanced serach functions to see if my question has already been addressed, but I get no results.

    My search was in PHP forums for:

    cursor landing & cursor position

    What I need to do is to have the cursor "land" into the username entry box when one visits the site to log in please?

    Thank-you all in advance,

    jim
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Can't give an exact example, but to help your research you need the onLoad() function and the focus command.
    It is something like [PHP]<body onLoad="documen t.id.focus()">[/PHP]

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      PHP can't control this. I'm not sure if javascript can, either. But this question is more relevant to JS.

      --Moving to JS

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        The word to search for is "focus". Code green was along the right lines, though it would probably result in errors. You can use something like:
        Code:
        <body onload="document.getElementById('idOfElement').focus();">

        Comment

        • trochia
          New Member
          • Oct 2008
          • 19

          #5
          First of all, I would like to thank all three of you for the replies so far.

          And I am sorry for my late one, but I never got an e-mail notify of a reply, and I think the below is why...and mabe the "coders" of the forums, could fix this?

          code_green, thank-you for the intial direction, but I didn't get back to the forums here until today.

          Markus? Sorry about tossing into the php forum, and thx for moving it...but it seems once it got moved, the "subscribe flagging" got lost. As this also happened in my very first post on bytes a few weeks ago, when you moved one.

          Just thought I'd mention that...so thank's again.

          Now, to the nitty - gritty I have been staring at for the past hour on and off since reading this.

          The first thing I did was to do a local disk search on my box here to see if I anything containing the phrase
          body onLoad
          in which I knew I would find a few.

          Now, acoder, I thank-you VERY much for the goal I need to obtain, but here is where I am stuck trying to figure this out, and where to place it.

          The first "instance" of it I had, was in an index.php file, (one of which I am not using nor worried about at this moment and has NOTHING to do with the code I am trying to modify...a whole nother set of scripts), but thought it could explain to me by reading it coming after /head and goes like this:
          [PHP]
          </head>

          <body onload="documen t.whois.domain. focus();">
          <h5>Search for a domain</h5>
          <form action="" name="whois" id="whois">
          <label for="domain">do main:</label>
          <input type="text" name="domain" id="domain" onkeyup="checkD omain()" />
          <div id="result"></div>
          </form>
          [/PHP]

          My html form, is where I would suspect I need to place this, and it looks like this: It is called example.html and it is plulled from another file (index.php)

          [php]$out = implode("\n", file('example.h tml'));[/php]

          In which a function I haven't even played with yet, so I am not sure if I am looking in the right place?

          [PHP]
          <table>
          <tr><td bgcolor="#55aaf f">
          <form method="get" action="{self}" >

          <table>
          <tr><td colspan=2>
          <center>
          <b> Welcome to my Whois is lookup routine</b><br>
          <b>Enter any domain name, ip address or <br> AS handle you would like to query whois for</b>
          <br></br>
          <input name="query"></input> <input type="submit" value="Whois"></input>
          </center>
          </td></tr>

          <tr><td>
          <input type="radio" name="output" value="normal" checked></input> Regular output
          <br></br>
          <input type="radio" name="output" value="nice"></input> HTMLized output
          <br></br>
          <input type="radio" name="output" value="object"> </input> Raw PHP object
          </td>
          [/PHP]

          I am getting confused staring at "form action" and"form method" trying to figure this out, or if I am even in the proper place.

          I am new to php/mysql etc...but not to programming... and again, thx for the replies...but I feel I am missing something easy here.

          Jim

          ps.. Markus, it shows an Unsubscribe option for me to click on here, but could you check the exact status for me?...As I should get an email reply?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            The first index.php is correct and that would work fine. The problem with your HTML file is that the form has no name, but if you give the input field an ID, then you can use document.getEle mentById(). In your index.php file containing example.html, find the body tag to add the onload. You can also use JavaScript to add the focus onload without messing with the HTML.

            PS. re. notification problems: that's a bug. The subscription gets reset to no notification when you make a post, so you need to edit the subscription to change the notification options.

            Comment

            • trochia
              New Member
              • Oct 2008
              • 19

              #7
              acoder, I again thank-you very much for the reply...and my late one.. ( e-mail notify, and I will go re-subscrime...I was figuring maybe because it got moved, it would reset)

              So, I looked, and it said "subscribed"... so I huess you mean by EDIT to unSubscribe, then re-subscribe each time?

              I screwed up, meaning the index.php example I gave above (or below) is NOT from the same project, I had just run a search on my drive...found an instance, or thought I could figure something out...(sigh)

              As for
              In your index.php file containing example.html, find the body tag to add the onload. You can also use JavaScript to add the focus onload without messing with the HTML.
              In the code, there is "no body tag" in the index.php file, and I feel sorry about including it here, but I think what you are saying...or what I ?? Should Do ?? is add one somewhere?

              Below is complete index.php file, that calls example.html

              [PHP]
              <?php
              /*
              Whois.php PHP classes to conduct whois queries
              Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic
              Maintained by David Saez (david@ols.es)
              For the most recent version of this package visit:
              http://www.phpwhois.or g
              This program is free software; you can redistribute it and/or
              modify it under the terms of the GNU General Public License
              as published by the Free Software Foundation; either version 2
              of the License, or (at your option) any later version.
              This program is distributed in the hope that it will be useful,
              but WITHOUT ANY WARRANTY; without even the implied warranty of
              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
              GNU General Public License for more details.
              You should have received a copy of the GNU General Public License
              along with this program; if not, write to the Free Software
              Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
              */

              header('Content-Type: text/html; charset=UTF-8');

              $out = implode("\n", file('example.h tml'));

              $out = str_replace('{s elf}', $_SERVER['PHP_SELF'], $out);

              $resout = extract_block($ out, 'results');

              if (isSet($_GET['query']))
              {
              $query = $_GET['query'];

              if (!empty($_GET['output']))
              $output = $_GET['output'];
              else
              $output = '';

              include_once('w hois.main.php') ;
              include_once('w hois.utils.php' );

              $whois = new Whois();

              // Set to true if you want to allow proxy requests
              $allowproxy = false;

              // uncomment the following line to get faster but less acurate results
              // $whois->deep_whois = false;

              // To use special whois servers (see README)
              //$whois->UseServer('uk' ,'whois.nic.uk: 1043?{hname} {ip} {query}');
              //$whois->UseServer('au' ,'whois-check.ausregist ry.net.au');

              // uncomment the following line to add support for non ICANN tld's
              // $whois->non_icann = true;

              $result = $whois->Lookup($query) ;

              $resout = str_replace('{q uery}', $query, $resout);
              $winfo = '';

              switch ($output)
              {
              case 'object':
              if ($whois->Query['status'] < 0)
              {
              $winfo = implode($whois->Query['errstr'],"\n<br></br>");
              }
              else
              {
              $utils = new utils;
              $winfo = $utils->showObject($re sult);
              }
              break;

              case 'nice':
              if (!empty($result['rawdata']))
              {
              $utils = new utils;
              $winfo = $utils->showHTML($resu lt);
              }
              else
              {
              if (isset($whois->Query['errstr']))
              $winfo = implode($whois->Query['errstr'],"\n<br></br>");
              else
              $winfo = 'Unexpected error';
              }
              break;

              case 'proxy':
              if ($allowproxy)
              exit(serialize( $result));

              default:
              if(!empty($resu lt['rawdata']))
              {
              $winfo .= '<pre>'.implode ($result['rawdata'],"\n").'</pre>';
              }
              else
              {
              $winfo = implode($whois->Query['errstr'],"\n<br></br>");
              }
              }

              $winfo = utf8_encode($wi nfo);

              $resout = str_replace('{r esult}', $winfo, $resout);
              }
              else
              $resout = '';

              echo str_replace('{r esults}', $resout, $out);

              //-------------------------------------------------------------------------

              function extract_block (&$plantilla,$m ark,$retmark='' )
              {
              $start = strpos($plantil la,'<!--'.$mark.'-->');
              $final = strpos($plantil la,'<!--/'.$mark.'-->');

              if ($start === false || $final === false) return;

              $ini = $start+7+strlen ($mark);

              $ret=substr($pl antilla,$ini,$f inal-$ini);

              $final+=8+strle n($mark);

              if ($retmark===fal se)
              $plantilla=subs tr($plantilla,0 ,$start).substr ($plantilla,$fi nal);
              else
              {
              if ($retmark=='') $retmark=$mark;
              $plantilla=subs tr($plantilla,0 ,$start).'{'.$r etmark.'}'.subs tr($plantilla,$ final);
              }

              return $ret;
              }
              ?>
              [/PHP]

              Comment

              • trochia
                New Member
                • Oct 2008
                • 19

                #8
                Update, acoder...again, thx for everything... and thx for your help., for know...please don't spend the time looking at it, as I haven't tested it yet...but I think I have resolved it....

                But I do need to get some sleep, lol...

                Jim

                Comment

                Working...