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

99
Views
Reemplace el texto al hacer clic en el botón de opción y vuelva a cambiarlo al texto original si se hace clic en otro botón de opción

El reemplazo de cadenas funciona bien para mí, pero ¿cómo devolver el texto de la etiqueta del último botón de opción al texto original?

 function myFunction(id) { var str = document.getElementById(id).innerHTML; var res = str.replace("{#var1#}", "<input type='text' name='var1' maxlength='30' size='30'>") .replace("{#var2#}", "<input type='text' name='var2' maxlength='30' size='30'>") .replace("{#var3#}", "<input type='text' name='var3' maxlength='30' size='30'>") .replace("{#var4#}", "<input type='text' name='var4' maxlength='30' size='30'>"); document.getElementById(id).innerHTML = res; }

Aquí está mi PHP, código HTML:

 <tr> <td><input onchange="myFunction('<?php echo $row['id']; ?>')" type="radio" name="id" value="<?php echo $row['id']; ?>" required></td> <td><b><?php echo htmlspecialchars($row['template_name']); ?></b></td> <td id="<?php echo $row['id']; ?>"><?php echo str_replace("\n","<br />",htmlspecialchars($row['template_content'])); ?></td> </tr>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que debería agregar un atributo adicional en la entrada (puede ser data-origin o algo así). Por ejemplo:

 <input value=""> <div class="display" data-origin="xxxx"></div>

Y luego haga que una función active el cambio en la entrada:

 $(input).onchange(() => { $(display).innerHtml = $(display).attr(data-origin) }); //===continue your stuff====
over 4 years ago · Santiago Trujillo 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!