andre
andre

Reputation: 1

Use a button instead a href to trigger div

I want to know if it's possible to use a button instead of href to trigger a div.

Here are examples below:

This is the current div:

<div id="ver" class="modal-block modal-block-primary mfp-hide">
<section class="panel">
    <header class="panel-heading">
        <h2 class="panel-title">Registration Form</h2>
    </header>
    <form class="form-horizontal mb-lg" method="POST" novalidate="novalidate">
    <div class="panel-body">

            <div class="form-group mt-lg">
                <label class="col-sm-3 control-label">Name</label>
                <div class="col-sm-9">
                    <input type="text" name="name" class="form-control" placeholder="Type your name..." required/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">Email</label>
                <div class="col-sm-9">
                    <input type="email" name="email" class="form-control" placeholder="Type your email..." required/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">URL</label>
                <div class="col-sm-9">
                    <input type="url" name="url" class="form-control" placeholder="Type an URL..." />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">Comment</label>
                <div class="col-sm-9">
                    <textarea rows="5" class="form-control" placeholder="Type your comment..." required></textarea>
                </div>
            </div>
    </div>
    <footer class="panel-footer">
        <div class="row">
            <div class="col-md-12 text-right">
                <input type="submit" name="ola" value="Submit">
                <button class="btn btn-default modal-dismiss">Cancel</button>
            </div>
        </div>
    </footer>
    </form>
</section>

This is how I can trigger it using href:

<a class="modal-with-form btn btn-default" href="#ver">Open Form</a>

This is how I tried:

<a class="modal-with-form btn btn-default" href="#ver?id=$ausenciaid">Open Form</a>

But it didn't work , there is a way to use a button instead of href?

Upvotes: 0

Views: 134

Answers (2)

Iceman
Iceman

Reputation: 6145

Less recommended inline way:

<button onclick="location.href='Your location';"> Open Form" </button>

OR

Attach Event & trigger using javascript:

<button type="button" id="mybutton" >Open Form </button>
<script>
document.getElementById("mybutton").addEventListener("click", function(){
    window.location.href = <input type="button" onclick="location.href='Your location';
});
</script>

Upvotes: 0

Rafael Shkembi
Rafael Shkembi

Reputation: 766

you can try this

<input type="button" onclick="location.href='Your location';" value="Open Form" />

This will give you a button and when you click on it you will transfer/open your href

Upvotes: 2

Related Questions