Update: Just for the record, you do not need to use jQuery-ui, it might be another solution.
I'm creating a autocomplete
for a form, which should include all the options of the CBO - Brazilian Code of Occupations
Unlike the zip code, that does not have a free official database , in the MTE Download Area there is a txt file, where the professions and the code of each are listed (inside the link page above it has the link: Estrutura CBO (TXT) - Arquivo ZIP (106kb)
- is the fourth file, CBO2002-Ocupacao.txt
).
So what I want is to get this file and generate the code automatically, including the professions and their CBO numbers in the .js file (as in the full example below). Is this possible?
I've already created autocomplete
, using the JQuery-ui plugin, but I got discouraged from writing all the professions and codes in the nail and here I am.
Also, I need the code not to be too heavy and slow to load. What is the best way to do this? With database, all in the .js file?
This is autocomplete
(I put all the external links and it works in "execute code snippet"):
$(function() {
var ocupacao = [
"Abacaxicultor (CBO 6125-10)",
"Abade (CBO 2631-05)",
"Abadessa (CBO 2631-05)",
"Abanador na agricultura (CBO 6220-20)",
"Abastecedor de caldeira (CBO 8621-20)",
"Abastecedor de linha de produção (CBO 7842-05)",
"Abastecedor de máquinas de linha de produção (CBO 7842-05)",
"Abastecedor de silos de carvão (CBO 6326-05)",
"Abatedor (CBO 8485-05)"
];
$("#profiss"). autocomplete({
source:ocupacao
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script><formmethod="post" id="Cpost" name="Tpost">
<input type="text" id="profiss" placeholder="Informe a profissão"/>
</form>
So, in short, the doubts are as follows:
1 - Is it possible to create the code automatically from the .txt (or html) file? How to do this?
2 - How to make loading options not slow.
Updating: I still can not, I even made another file with the line breaks (it seems that what can be downloaded in the site does not have line breaks) to test, but I still can not do it script to work. Getting, put the result here, but if anyone has another idea I'm accepting it too. :)
Update: I converted the pdf to html file, and it got the following structure (the whole file has over 65k lines):
<DIV id="id_1">
<DIV id="id_1_1">
<TABLE cellpadding=0 cellspacing=0 class="t2">
<TR>
<TD class="tr5 td4"><P class="p9 ft2"><NOBR>7681-25</NOBR></P></TD>
<TD class="tr5 td5"><P class="p10 ft3">Acabador de chapéus de palha</P></TD>
</TR>
<TR>
<TD class="tr6 td4"><P class="p9 ft2"><NOBR>7663-05</NOBR></P></TD>
<TD class="tr6 td5"><P class="p10 ft4">Acabador de embalagens (flexíveis e cartotécnicas)</P></TD>
</TR>
</TABLE>
</DIV>
Does this help?
/ upate