Fix auto focus on module page

This commit is contained in:
Laurent Destailleur 2017-06-16 16:06:20 +02:00
parent 549bb2c55f
commit b228fe6a2a
2 changed files with 5 additions and 3 deletions

View File

@ -430,6 +430,8 @@ print "<br>\n";
if ($mode == 'common')
{
dol_set_focus('#search_keyword');
print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -441,7 +443,7 @@ if ($mode == 'common')
$moreforfilter = '';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('Keyword') . ': <input type="text" name="search_keyword" value="'.dol_escape_htmltag($search_keyword).'">';
$moreforfilter.= $langs->trans('Keyword') . ': <input type="text" id="search_keyword" name="search_keyword" value="'.dol_escape_htmltag($search_keyword).'">';
$moreforfilter.= '</div>';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1);

View File

@ -6089,12 +6089,12 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
/**
* Set focus onto field with selector
*
* @param string $selector Selector ('#id')
* @param string $selector Selector ('#id') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char.
* @return string HTML code to set focus
*/
function dol_set_focus($selector)
{
print '<!-- Set focus onto a specific field -->'."\n";
print "\n".'<!-- Set focus onto a specific field -->'."\n";
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("'.$selector.'").focus(); });</script>'."\n";
}