By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,746 Members | 1,306 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,746 IT Pros & Developers. It's quick & easy.

Cursor landing / position

P: 18
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,

Oct 24 '08 #1
Share this Question
Share on Google+
7 Replies

code green
Expert 100+
P: 1,726
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="">[/PHP]
Oct 24 '08 #2

Expert 5K+
P: 6,050
PHP can't control this. I'm not sure if javascript can, either. But this question is more relevant to JS.

--Moving to JS
Oct 24 '08 #3

Expert Mod 15k+
P: 16,027
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:
Expand|Select|Wrap|Line Numbers
  1. <body onload="document.getElementById('idOfElement').focus();">
Oct 25 '08 #4

P: 18
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 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:

<body onload="document.whois.domain.focus();">
<h5>Search for a domain</h5>
<form action="" name="whois" id="whois">
<label for="domain">domain:</label>
<input type="text" name="domain" id="domain" onkeyup="checkDomain()" />
<div id="result"></div>

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.html'));[/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?

<tr><td bgcolor="#55aaff">
<form method="get" action="{self}">

<tr><td colspan=2>
<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>
<input name="query"></input> <input type="submit" value="Whois"></input>

<input type="radio" name="output" value="normal" checked></input> Regular output
<input type="radio" name="output" value="nice"></input> HTMLized output
<input type="radio" name="output" value="object"></input> Raw PHP object

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.


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?
Oct 25 '08 #5

Expert Mod 15k+
P: 16,027
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.getElementById(). 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.
Oct 25 '08 #6

P: 18
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" 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

Whois.php PHP classes to conduct whois queries
Copyright (C)1999,2005 easyDNS Technologies Inc. & Mark Jeftovic
Maintained by David Saez (
For the most recent version of this package visit:
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
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.html'));

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

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

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

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


$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','{hname} {ip} {query}');

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

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

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

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

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

case 'proxy':
if ($allowproxy)

$winfo .= '<pre>'.implode($result['rawdata'],"\n").'</pre>';
$winfo = implode($whois->Query['errstr'],"\n<br></br>");

$winfo = utf8_encode($winfo);

$resout = str_replace('{result}', $winfo, $resout);
$resout = '';

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


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

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

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



if ($retmark===false)
$plantilla=substr($plantilla,0,$start).substr($pla ntilla,$final);
if ($retmark=='') $retmark=$mark;
$plantilla=substr($plantilla,0,$start).'{'.$retmar k.'}'.substr($plantilla,$final);

return $ret;
Oct 25 '08 #7

P: 18
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...

Oct 26 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.