Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Javascript password + button open URL in targeted element

I learned how to open a link using a password and button. I used the following code:

<input type="text" id="text" />
<input type="button" id="btn" value="Submit" onClick="window.location=url;" />

<script>
$("#btn").click(function() {
window.location="example.com/"+$("#text").val();})
</script>

What I would like to figure out is whether I can target a div element for the link to open within.

I've been using the following script to load html pages into a specified div element with a link:

<div class="item1" id="pageone"></div>
<a href="" onclick="loadSAMEDiv1(); return false;">link</a>

<script>
function loadSAMEDiv1() { 
$.ajax({ 
 url: 'item1.html', 
 success: function(data) { 
      $('#pageone').html(data); 
 } 
 }); 
} 
</script>

I guess I'm wondering if there's a way to make the password url made by the first script open in a targeted div, like it does in the second script. So when you click the button element it will make the url using the password entered into the text box and load it into a div like #pageone.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The simplest way to do this is with Ajax load(). Try this.

<input type="text" id="text" />
<input type="button" id="btn" value="Submit"/>

<div class="item1" id="pageone"></div>

<script>
    $("#btn").on("click", function() {
        $("#pageone").load("example.com/"+$("#text").val());
    });
</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda