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
Views: 1,064
Zen Follower
I want to have cursor in search sidebox on every page
Zen Follower
NO one willing to help....???????
Black Belt
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.
Zen Follower
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.
Black Belt
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.
Black Belt
This is an "onload" event that goes in the body tag. Look in the tutorials or wiki for info on how to get this automatically added via javascript without editing any existing files.
Zen Follower
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
Zen Follower
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
Zen Follower
Hey thanks heaps i cudnt do better without u.
thanks
Black Belt
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() ```Zen Follower
Here is Complete Guide:
Make a folder on_load in includes/templates/TEMPLATE/jscript/
create a file on_load_*.js inside that folder
copy document.getElementById('YOUR_DEFINED_NAME').focus(); inside your file
go to includes/templates/TEMPLATE/sidebox/tpl_search.php
Look for zen_draw_input_field('Keyword'.... and define id="YOUR_DEFINED_NAME"
its done.
Black Belt
From mediacollege.com:
"The following example shows a text field in a 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()
Fields marked required must be completed.
Tell staff why this post should be reviewed.