Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Cursor starting in Search form?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 12-11-2006, 09:41 AM
 
gravel gravel is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 156
 

Default 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
__________________
X-Cart version 4.0.17
X-Cart version 4.0.18
Web servers = Apache
OS = Linux
Reply With Quote
  #2  
Old 12-11-2006, 09:58 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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()"

__________________
xcartmods.co.uk
Reply With Quote
  #3  
Old 12-11-2006, 10:09 AM
 
gravel gravel is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 156
 

Default Re: Cursor starting in Search form?

That works! Really excellent - thanks.

--Daniel
__________________
X-Cart version 4.0.17
X-Cart version 4.0.18
Web servers = Apache
OS = Linux
Reply With Quote
  #4  
Old 12-12-2006, 02:51 PM
 
gravel gravel is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 156
 

Default 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.
__________________
X-Cart version 4.0.17
X-Cart version 4.0.18
Web servers = Apache
OS = Linux
Reply With Quote
  #5  
Old 11-08-2007, 02:01 PM
 
gravel gravel is offline
 

Senior Member
  
Join Date: Mar 2004
Posts: 156
 

Default 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()">
__________________
X-Cart version 4.0.17
X-Cart version 4.0.18
Web servers = Apache
OS = Linux
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:40 PM.

   

 
X-Cart forums © 2001-2020