Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
¿Cómo puedo hacer clic en un botón cuando el parámetro está en la URL (error: el clic no es una función)

Quiero que JavaScript haga clic en un botón cuando haya un parámetro en la URL (&startCalc=1).

html:

 <input name="startCalc" value="Start" type="submit">

JavaScript:

 var parameterExists = url.searchParams.get("startCalc"); if(typeof parameterExists !== 'undefined' && parameterExists == 1) { document.getElementsByName('startCalc').click(); }

Me sale un error: "hacer clic no es una función". Quiero simular un clic de la misma manera que lo haría un usuario al hacer clic en ese botón...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Dos cosas que necesita cambiar Primero el parámetro de búsqueda en la URL y segundo cuando obtiene el botón por nombre, obtiene una matriz, por lo que debe especificar el índice de eso. Verifique el código a continuación: DEMO

 let url = "https://jsfiddle.net&startCalc=1"; // Suppose you are getting url in here let urlParams = new URLSearchParams(url); let parameterExists = urlParams.get('startCalc'); if(typeof parameterExists !== 'undefined' && parameterExists == 1) { document.getElementsByName('startCalc')[0].click(); console.log('button clicked!') }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!