By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 3,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 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,

jim
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="document.id.focus()">[/PHP]
Oct 24 '08 #2

Markus
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

acoder
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 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="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>
</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.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?

[PHP]
<table>
<tr><td bgcolor="#55aaff">
<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?
Oct 25 '08 #5

acoder
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"...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.org
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.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'];
else
$output = '';

include_once('whois.main.php');
include_once('whois.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.ausregistry.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('{query}', $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($result);
}
break;

case 'nice':
if (!empty($result['rawdata']))
{
$utils = new utils;
$winfo = $utils->showHTML($result);
}
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($result['rawdata']))
{
$winfo .= '<pre>'.implode($result['rawdata'],"\n").'</pre>';
}
else
{
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
}
}

$winfo = utf8_encode($winfo);

$resout = str_replace('{result}', $winfo, $resout);
}
else
$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);

$ret=substr($plantilla,$ini,$final-$ini);

$final+=8+strlen($mark);

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

return $ret;
}
?>
[/PHP]
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...

Jim
Oct 26 '08 #8

Post your reply

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