Zen Cart Logo
Forums / General Questions / Have cursor in search sidebox

Have cursor in search sidebox

Locked

Views: 1,064

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
2 Dec 2010, 12:15 AM
#1
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Have cursor in search sidebox

I want to have cursor in search sidebox on every page

2 Dec 2010, 11:53 PM
#2
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

NO one willing to help....???????

3 Dec 2010, 8:44 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Have cursor in search sidebox

Your question is cryptic. Maybe nobody else understands what you want, either. In what way would you have a "cursor" in the search sidebox? We need more info to help you.

7 Dec 2010, 12:25 AM
#4
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

I apologise for that....even its really hard for me to tel exactly :cool:

What i want is when i load a page the cursor should be in search box so its ready to type in without using mouse to click on search box first.

7 Dec 2010, 12:40 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Have cursor in search sidebox

I believe that is known as "focus". You may need some javascript to get default focus in that location. This is fundamentally a generic HTML/javascript problem, and you should be able to get info by searching the web for it.

7 Dec 2010, 2:00 AM
#7
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

Thanks for your help...i have created on_load file..having some problems

how can i confirm wat is the element name in tpl_search.php

$content .= zen_draw_input_field('keyword', '', 'size="18" maxlength="100" style="width: ' . ($column_width-30) . 'px"') . '<br />' . zen_image_submit (BUTTON_IMAGE_SEARCH,HEADER_SEARCH_BUTTON);

i guess its keyword..but its not working

7 Dec 2010, 2:05 AM
#8
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

i added the id field in there

$content .= zen_draw_input_field('keyword', '', 'size="18" id="keyword" maxlength="100" style="width: ' . ($column_width-30) . 'px"') . '<br />' . zen_image_submit (BUTTON_IMAGE_SEARCH,HEADER_SEARCH_BUTTON);

but still no luck

7 Dec 2010, 2:06 AM
#9
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

Hey thanks heaps i cudnt do better without u.

thanks

7 Dec 2010, 2:57 AM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Have cursor in search sidebox

The default search sidebox has this HTML```

<div id="searchContent" class="sideBoxContent centeredContent"> <form name="quick_find" action="http://localhost/fr-zc139gfresh/index.php?main_page=advanced_search_result" method="get"> <input type="hidden" name="main_page" value="advanced_search_result" /><input type="hidden" name="search_in_description" value="1" /> <input type="text" name="keyword" size="18" maxlength="100" style="width: 120px" value="Enter search keywords here" onfocus="if (this.value == 'Enter search keywords here') this.value = '';" onblur="if (this.value == '') this.value = 'Enter search keywords here';" /><br /> <input type="submit" value="Search" style="width: 50px" /><br /><a href="http://localhost/fr-zc139gfresh/index.php?main_page=advanced_search">Advanced Search</a></form></div></div> ```so I would say the on_load_.js file should be``` quick_find.keyword.focus() ```
7 Dec 2010, 3:27 AM
#11
gaurav10feb avatar

gaurav10feb

Zen Follower

Join Date:
Jan 2010
Location:
Australia
Posts:
243
Plugin Contributions:
1

Re: Have cursor in search sidebox

Here is Complete Guide:

  1. Make a folder on_load in includes/templates/TEMPLATE/jscript/

  2. create a file on_load_*.js inside that folder

  3. copy document.getElementById('YOUR_DEFINED_NAME').focus(); inside your file

  4. go to includes/templates/TEMPLATE/sidebox/tpl_search.php

  5. Look for zen_draw_input_field('Keyword'.... and define id="YOUR_DEFINED_NAME"

  6. its done.

7 Dec 2010, 3:48 AM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Have cursor in search sidebox

From mediacollege.com:
"The following example shows a text field in a form:

<form name="myform"> <input type="text" name="mytextfield"> </form>

Add the following code to the body tag, substituting the form and field names for your own:

<body OnLoad="document.myform.mytextfield.focus();">

That's all there is to it — the OnLoad command instructs the browser to wait until all elements are loaded and then set the focus to the specified form/text field."

Since the on_load_xxx.js content will be put between the quotes in the Zen Cart <body> tag, it looks like its content could be```
document.quick_find.keyword.focus()