Jose Saiz

Jose Saiz

  • 1.5k
  • 260
  • 103.2k

Help on pushing a hidden button with javascript

Mar 30 2020 12:00 PM
Hi Guys, I've having problem trying to trigger a hidden button with javascript I have the following code
 
  1. <script>  
  2.         document.getElementById("myBtn").onclick = doFunction;  
  3. </script>  
  4.   
  5.  <a href="#" onclick="javascript:doFunction();">Request a quote</a>   
  6.   
  7.  <input type="hidden" id="myBtn" value="REQUEST A QUOTE" />  
  8.   
  9.   <div id="myModal" class="modal">  
  10.         <!-- Modal content -->  
  11.         <div class="modal-content">  
  12.             <div class="modal-header">  
  13.                 <span class="close">×</span>  
  14.                     <h2>Quote</h2>  
  15.              </div>  
  16.              <div class="modal-body">  
  17.                   <cc1:GetQuote ID="ctrl1" runat="server" />    
  18.              </div>  
  19.              <div class="modal-footer">  
  20.                   <h3>Medicare Advantage & Medicare Supplement Quote</h3>  
  21.              </div>  
  22.         </div>  
  23.    </div>  
 As you notice I try to push the hidden button using a <a href="" onclick="javascript:doFunction():">Request Quote</a> instead of using the input button, but somehow it does not trigger it.
 
If I changed the Type=hidden" button to type="button" and click on the button then the popup modal works with no problem, but I do not want to use the button instead I'd like to use the <a href=""></a> tag to keep my web template to look as it should.
 
Also how can I trigger the close [X] from the popup modal by adding an input button inside the form instead clicking the Top->Right->[X] Close link on the popup modal.
 
Thank you guys 
 
 

Answers (5)