title: I can't retrieve the value typed in a text input using Javascript
body: <p>I have a problem, when i try to retrieve the value I have typed in the text input, and I try to print it in alert , it shows nothing, the variable is empty
  here is the code:
  <br/> I have here the input textfield 'Montant', i would like to retrieve it using the onClick event on the button on the bottom</p>
  
  <pre><code>&lt;form  name="formEspece" method="get" action="{{route('EffectuerPaiement')}}" &gt;
  &lt;div class="modal-body"&gt;
      &lt;p&gt;Veuillez saisir le montant à payer pour cette échéance&lt;/p&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="exampleInputEmail1"&gt;Montant:&lt;/label&gt;
              &lt;input required type="number" id="idMontant1"class="form-control" placeholder="Saisissez un montant" name="Montant" &gt;
          &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="modal-footer"&gt;
      &lt;input type="button" class="btn btn-primary" onclick='return test(document.getElementById("idMontant1").value,{{$paiement-&gt;montant-$totalPaiement}})' value="valider"/&gt;
  &lt;/div&gt;&lt;/form&gt;
  </code></pre>
  
  <p>here is the script:</p>
  
  <pre><code>&lt;script&gt;function test(a,b){
  window.alert('a= '+a+'b= '+b);}&lt;/script&gt;
  </code></pre>
  
  <p>it shows nothing, notice that i am using Bootstrap, and LARAVEL</p>
  
  <p>here is a more detailed code I retreive it from my own project:</p>
  
  <pre><code>@foreach($inscriptions as $inscription)
  &lt;?php
  // some treatments
  ?&gt;
  &lt;tr  class="{{$rowstyle}}"&gt;
      &lt;td&gt;&lt;img src="images/{{ $inscription-&gt;photo }}"&gt;&lt;/td&gt;
      &lt;td&gt;{{ $inscription-&gt;cne }}&lt;/td&gt;
      &lt;td&gt;{{ $inscription-&gt;nom }}&lt;/td&gt;
      &lt;td&gt;{{ $inscription-&gt;prenom }}&lt;/td&gt;
      &lt;td&gt;{{ $inscription-&gt;ville }}&lt;/td&gt;
      &lt;!-- the  button  who open the forms modal--&gt;
      &lt;td&gt;
          &lt;button class="btn btn-sm btn-primary btn-success" data-toggle="modal" data-target="{{"#smallModalEspece".$count}}"&gt;Espèce&lt;/button&gt;
      &lt;/td&gt;
      &lt;td&gt;
          &lt;a class="btn btn-sm btn-danger" href="{{ route('retirer',[ 'cne' =&gt; $inscription-&gt;cne ]) }}"&gt;&lt;i class="fa fa-trash-o"&gt;&lt;/i&gt;&lt;/a&gt;
          &lt;a href="{{ route('detailetudiant',[ 'id' =&gt; $inscription-&gt;id ]) }}" class="btn btn-sm btn-default"&gt;
              &lt;i class="fa fa-info-circle"&gt;&lt;/i&gt; Détails
          &lt;/a&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;!-- the modal who contains the form --&gt;
  
  &lt;div id="{{"smallModalEspece".$count}}" class="modal fade" tabindex="-1" role="dialog"&gt;
          &lt;div class="modal-dialog modal-sm"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
                      &lt;h4 class="modal-title"&gt;Paiement en espèce&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;form  name="formEspece" method="get" action="{{route('EffectuerPaiement')}}" &gt;
                      &lt;div class="modal-body"&gt;
                          &lt;h3&gt;Le montant restant à payer pour l'étudiant {{\fc\etudiant::find($inscription-&gt;cne)-&gt;nom.' '.\fc\etudiant::find($inscription-&gt;cne)-&gt;prenom}} est : {{$paiement-&gt;montant-$totalPaiement}}&lt;/h3&gt;
                          &lt;p&gt;Veuillez saisir le montant à payer pour cette écheance&lt;/p&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input type="hidden" name="MontantPaye" value="{{$paiement-&gt;montant-$totalPaiement}}"/&gt;
                                  &lt;label for="exampleInputEmail1"&gt;Montant:&lt;/label&gt;
                                  &lt;input required type="number" id="idMontant1"class="form-control" placeholder="Saisissez un montant" name="Montant" &gt;
                              &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="modal-footer"&gt;
                          &lt;input type="hidden" name="_token" value=" {{ csrf_token() }} "&gt;
                          &lt;input type="hidden" name="idpaiment"  value="{{$paiement-&gt;idPaiement}}"&gt;
                          &lt;input type="hidden" name="nbrEcheance"  value="{{$nbrE}}"&gt;
                          &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Cancel&lt;/button&gt;
                          &lt;input type="button" id="#buttonid" class="btn btn-primary" onclick='test(document.getElementById("idMontant1").value,{{$paiement-&gt;montant-$totalPaiement}})' value="valider"/&gt;
                      &lt;/div&gt;
  
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  @endforeach
  </code></pre>