Resnef Immatong
Resnef Immatong

Reputation: 55

How to get input value when the link is outside form in laravel?

Im not pro in web dev and Im having a hard time on how can I get the values of inputs inside a form when one of my button or link is outside the form.. Because in my for, I assigned it already for my search button, but I also need those values when I click Export Data to Excel. Below is my code..Please help me.

<form class="form-horizontal" action="{{ url('award_search') }}" method="GET">
                    {{ csrf_field() }}
<fieldset>

<!-- Search Navbar -->
<nav class="navbar navbar-default no-border">
  <div class="container-fluid">

                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                              <span class="sr-only">Toggle navigation</span>
                              <span class="icon-bar"></span>
                              <span class="icon-bar"></span>
                              <span class="icon-bar"></span>
                            </button>
                              <a class="navbar-brand" href="#">Filter Search: </a>
                          </div>
<!-- Brand and toggle get grouped for better mobile display -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" style="margin-top: 5px;">
<ul class="nav navbar-nav">
<li>
                            <div class="btn-group" role="group" style="width:100%;">
                              <select class="form-control" id="s" name="s">
                                <option  value="0" selected>Select a Area</option>           
                                @foreach($areas as $area)
                                  <option value="{{$area->area_code}}">{{$area->area_name}}</option>
                                @endforeach
                              </select>
                          </div>
</li>
<li>
                          <div class="btn-group" role="group" style="width:100%;">
                        <select class="form-control" id="sys" name="sys">
                        </select>
                          </div>
</li>
<li>
                          <div class="btn-group" role="group" style="width:100%;">
                              <button type="submit" id="btnSearch" class="btn btn-primary form-control" style="border-radius: 0px;">Search</button>
                          </div>
</li>
</ul>
    </div>
  </div><!-- /.container-fluid -->
</nav>
<!-- End of Search Navbar -->

</fieldset>
</form>

And outside the form is my Export to Excel Link:

<a href="{{ url('/getExportAwardExcel') }}" class="btn btn-success btn-md" style="border-radius: 0px;text-align: left;"><span class="glyphicon glyphicon-export"></span> Export to Excel</a>

Now, how can I use the variable inputted inside the form for my Export to Excel link? I need solid answer please, If possible, no JS for this function..

Upvotes: 0

Views: 939

Answers (1)

Vaibhav Tyagi
Vaibhav Tyagi

Reputation: 23

You can make use of html5 form attribute:

<form Id='myform' class='form-horizontal'>
Your data...
<form>

Then attached this id to your outside anchor tag:

<a href='' form='myform`>

Upvotes: 1

Related Questions