How do I reference another option HTML in my datalist?

Asked

Viewed 41 times

1

I have over 5,000 lines to put as an option within a datalist. I have already managed to leave all my options in the correct format, however I did not want to leave this lot of line in my main HTML. Is there any way to put all these 5,000 options in another HTML and make a reference in my main HTML so that the datalist searches those options there in that other HTML?

In my main HTML I did so:

<datalist id="cidades">
                <option value="Rio de Janeiro"></option>
                <option value="Nova Iguaçu"></option>
                <option value="Niterói"></option>
                <option value="Belford Roxo"></option>
            </datalist>

In my other HTML, I did so:

<!DOCTYPE html>
<html lang="pt-br" dir="ltr">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="UTF-8">
    <title>Cidades Brasileiras</title>
</head>
<body>

<datalist id="cidades">
    <option value="Afonso Cláudio"></option>
    <option value="Água Doce do Norte"></option>
    <option value="Águia Branca"></option>
    <option value="Alegre"></option>
    <option value="Alfredo Chaves"></option>
    <option value="Alto Rio Novo"></option>
    <option value="Anchieta"></option>
    <option value="Apiacá"></option>
    <option value="Aracruz"></option>
    <option value="Atilio Vivacqua"></option>
...

Is there to do this here or am I traveling too much:

<datalist URL="cidades.html#cidades">

</datalist>
  • I don’t know exactly but sometimes with ajax you can treat it

  • Would code the options in JS or iframe suit you? Type: https://repl.it/repls/SoupyAquaCopyleft or https://repl.it/repls/BossyPowderblueOolanguage

  • I will see if these solutions meet me. Thank you very much for the reference.

  • It worked Daniel, thank you very much. I used the iframe solution. I just need to solve the field stylization issue, it was very distorted after incorporating iframe. But thanks for the help. Forte Abraço.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.