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

357
Visualizações
Input user name and email id and download pdf certificate with same name (name+emailid) from a folder

Can you correct the code below so that a user inputs his firstname and email id and his PDF certificate with same (firstname and email id) is downloaded from OOEcertificate folder

Call a JavaScript function
     function myFunction()
    {
        var downloadUrl = document.getElementById("url").value;
        document.getElementById("downlod").href = '/ooecertificate' + downloadUrl + '.pdf';
    }
    
    alert("You are Successfully Called the JavaScript function");  
     }  
<div>
        <label>ENTER YOUR REGISTRATION ID:</label> 
        <br> </br>
        
        <label>(Your registration id is your firstname+registered email id:
                for example if your name is SAMMY DIXIT and 
                your registered email id is SAMMY.DIXIT@GMAIL.COM
                your REGISTRATION ID WILL BE: SAMMYSAMMY.DIXIT@GMAIL.COM
        </label> 
        
        <input type="text" name="url" id="url" onkeyup="myFunction()"> 
        
        <a href="/OOEcertificate" id="downlod" download><span>Download</span></a>
        
    </div>
    </div>   
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is a demo starting from your code that will fetch the value from the input box #url and will use that value to compose the url string that will be used to navigate the browser to the pdf download.

Such behaviour is obtained with window.location.href that I commented to make the demo working here. On its behalf it will show the url in the console.

function downloadPdf(){    
    
    //fetch the registrationId from the input#url
    let registrationId = document.getElementById("url").value;        
    
    //transform the registrationId string to lower case
    registrationId = registrationId.trim().toLowerCase();
    
    const pdfUrl = `/ooecertificate/${registrationId}.pdf`;        
    
    //this is the statement to redirect the browser to the wanted url
    //now commented because it wouldn't work here on the snippet
    
    //window.location.href = pdfUrl;
    
    //on its behalf I'm writing the url on console
    console.log(pdfUrl);
}
label.fieldLabel{
  display: block;
  margin-bottom: 1rem;
}

label.fieldDescription{
  display: block;
  margin-bottom: 1rem;   
  border: solid 1px gray;
  padding: 1em;
}

button{
  cursor: pointer;
}
<div>
  <label class="fieldDescription">
  Your registration id is your firstname+registered email id:<br>
  For example..<br>
  if your name is SAMMY DIXIT and your registered email id is SAMMY.DIXIT@GMAIL.COM<br>
  your REGISTRATION ID WILL BE: <b>sammysammy.dixit@gmail.com</b>
  </label> 

  <label class="fieldLabel">ENTER YOUR REGISTRATION ID:</label>   

  <input type="text" name="url" id="url"> 

  <button onclick="downloadPdf();">Download</button>
  
</div>

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