Here is a snippet of code you can use to set the focus onLoad to a specific form field when a user loads an insert, edit or search form on your DaDaBIK powered web site.
Open your header.php and replace your <body> tag with the following:
/* Begin code
<?php if ($function === "show_insert_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
if ($function === "edit"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
if ($function === "show_search_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
echo "<body>";
}
}
}
?>
*/ End code
The default form name in DaDaBIK is contacts_form and was not changed in the above code. The parts of the code in bold above and below would be changed to the form field name in your form.
If your insert, edit and search forms happen to be the same or you want to focus on the same field name in all three form types you could use the code below:
/* Begin code
<?php if ($function === "show_insert_form" || $function === "edit" || $function === "show_search_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
echo "<body>";
}
?>
*/ End code
Note: I am not using the default header.php that was installed by DaDaBIK so your <body> tag in header.php will look different if you are working with a default installation.
You can see a working demo at http://dadabik.kicks-ass.net.
Open your header.php and replace your <body> tag with the following:
/* Begin code
<?php if ($function === "show_insert_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
if ($function === "edit"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
if ($function === "show_search_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
echo "<body>";
}
}
}
?>
*/ End code
The default form name in DaDaBIK is contacts_form and was not changed in the above code. The parts of the code in bold above and below would be changed to the form field name in your form.
If your insert, edit and search forms happen to be the same or you want to focus on the same field name in all three form types you could use the code below:
/* Begin code
<?php if ($function === "show_insert_form" || $function === "edit" || $function === "show_search_form"){
echo "<body onLoad=\"document.contacts_form.your_form_field_name.focus()\">";
}
else {
echo "<body>";
}
?>
*/ End code
Note: I am not using the default header.php that was installed by DaDaBIK so your <body> tag in header.php will look different if you are working with a default installation.
You can see a working demo at http://dadabik.kicks-ass.net.