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

170
Visualizações
Opening new tab based on Javascript output (broken code)

I’m making a hosting site, and I am trying to have a form where you can search a domain from a form. Check out the pseudocode to understand what I’m trying to do.

User types domain/search in box -> Presses DONE -> Opens new tab with the below format (with the user’s query)

https://example.com/cart.php?a=add&domain=register&query=QUERY_HERE

Here’s my code, but when the form submission, it searches domain=example.com (if I put example.com in the search box). What did I do wrong?

JavaScript (with JQuery):

$('.done').on('click', function() {

    var dataArray = $('#message').serializeArray();
  
    window.open('https://billing.zapprhosting.com/cart.php?a=add&domain=register&query=' + $.param( dataArray ));
  
  });

HTML Form:

<form id="message" target="_blank">
    <input id="domain-text" type="text" name="domain" placeholder="Write your domain name here.." />
</form>
<div class="button-center done">
     <a href="#"><p>SUBMIT</p></a>
</div>

SOLUTION: This took some more reworking of how I tackled the problem, but this is the final code which works.

JavaScript:

$("#btn").click( function() {
    var url = "https://billing.zapprhosting.com/cart.php?a=add&domain=register&query=" + $("#text").val();
    window.open(url);
});

HTML:

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

Pretty simple page, but useful for scaling up to larger projects. Thanks for the help everyone :)

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

0

This took some more reworking of how I tackled the problem, but this is the final code which works.

JavaScript:

$("#btn").click( function() {
    var url = "https://billing.zapprhosting.com/cart.php?a=add&domain=register&query=" + $("#text").val();
    window.open(url);
});

HTML:

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

Pretty simple page, but useful for scaling up to larger projects. Thanks for the help everyone :)

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