Set focus on text field on custom page

johan

Member
Hi Eugineo

How can i set the focus on a textfield @ a custom page, so the cursor is blinking in the textfield.

I would like to use it for an barcodehandscanner.
And everytime I run the script I would like to go back to the textfield.

i'll wait for your answer.

regards Johan

====================
I tried:

<script type="text/javascript" language="JavaScript">
document.forms['myform'].elements['_cp_barcode'].focus();
</script>

but I'am not shure where to put this code

====================

You are using DaDaBIK version 9.2.1-Monterosso enterprise,

PHP Version: 7.0.10

mysql version: 5.7.14

Web server: Apache/2.4.23 (Win64) PHP/7.0.10

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
 

eugenio

Administrator
Staff member
Hello Johan,
if you are producing a custom PHP page, you can write your code as you want (respecting the rules about variable naming and so on).

If you have custom javascript code, you have to add it to the include/custom_functions.js file; you probably have to check with an IF statement if you are in your custom page (you can see that from the URL) otherwise the code will be executed in any page of your DaDaBIK app.

Best,
 

johan

Member
Tank you for your answer, I have found an easy way to set the focus.

<input type="text" name="fname" autofocus>

just add autofocus in de element does the work.
 
Top