X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Cursor starting in Search form? (https://forum.x-cart.com/showthread.php?t=27272)

gravel 12-11-2006 09:41 AM

Cursor starting in Search form?
 
When an X-Cart page is loaded, I want the cursor to automatically appear in the Search box. In search.tpl (skin1/customer/), I tried adding
tabindex="0"
or
tabindex="1"
to the text input form code, but it doesn't help.

The first "tab" I hit highlights the URL in the address bar (this is in IE7), the 2nd the Refresh button, 3rd browser Google search field, 4th-7th other browser buttons, finally the 8th tab shows a cursor in the Search field.

Many other web sites I use open a new page with the cursor in either their Login field or their Search field. Anybody solved this problem?

Thanks,
Dan

PhilJ 12-11-2006 09:58 AM

Re: Cursor starting in Search form?
 
In skin1/customer/home.tpl

Add this to your <body> tag

Code:

onLoad="document.getElementById('posted_data[substring]').focus()"

:)

gravel 12-11-2006 10:09 AM

Re: Cursor starting in Search form?
 
That works! Really excellent - thanks.

--Daniel

gravel 12-12-2006 02:51 PM

Re: Cursor starting in Search form?
 
This solution works in IE7, but not so much in Firefox 1.5.0.8.

With the search.tpl input form code using tabindex="1",
a new page in FF requires one hit of the "Tab" key,
to get the cursor to the Search box.
Set to tabindex="0", it requires 8 hits.

In IE7, either tabindex setting works - new pages load
with the cursor already there.

gravel 11-08-2007 02:01 PM

Re: Cursor starting in Search form?
 
I found something that works in both FF and IE, and no "error on page" msgs. It sets an ID for both the search form and the text box. For example:

In search.tpl:

Code:

<form method="get" action="search.php" name="search" id="formid">
 ...
<input type="text" name="whatever" id="textboxid"
 value="{$searchstring|escape:'html'}" onFocus="this.value=''"
tabindex="1" />
...
</form>

In home.tpl:

Code:

<body onload="document.forms.formid.textboxid.focus()">


All times are GMT -8. The time now is 12:01 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.