TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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
<script>
document.getElementById(
"myBtn"
).onclick = doFunction;
</script>
<a href=
"#"
onclick=
"javascript:doFunction();"
>Request a quote</a>
<input type=
"hidden"
id=
"myBtn"
value=
"REQUEST A QUOTE"
/>
<div id=
"myModal"
class
=
"modal"
>
<!-- Modal content -->
<div
class
=
"modal-content"
>
<div
class
=
"modal-header"
>
<span
class
=
"close"
>×</span>
<h2>Quote</h2>
</div>
<div
class
=
"modal-body"
>
<cc1:GetQuote ID=
"ctrl1"
runat=
"server"
/>
</div>
<div
class
=
"modal-footer"
>
<h3>Medicare Advantage & Medicare Supplement Quote</h3>
</div>
</div>
</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
Reply
Answers (
5
)
Datetime in a model not working
Updating identity table aspnetuser in mvc web application