2016-03-26 9 views
1

arbeiten Ich habe ein Formular, das verschiedene Auswahl Eingabemöglichkeiten hat und ich kann einfach nicht die erforderlichen Anweisungen zu arbeiten. Kann mir jemand sagen, was ich falsch mache oder nicht? Ich habe auch den oberen Teil meiner Seite eingefügt, wo der HTML-Code deklariert wird, falls er irgendwelche Hinweise bietet. (ich benutze jquery und ajax zum post form). Danke. HierKann nicht erforderlich, in Registerkarte

ist ein bootply, die funktioniert, aber aus irgendeinem Grund auf meiner Seite tut es nicht

Die JQuery

 <script> 
$(document).ready(function(){ 
$("#submitButtonId").on("click",function(e){ 
$('#gauge').empty(); 
    e.preventDefault(); 


//Post form 
var formdata = $(this.form).serialize(); 
    $.post('insert.php', formdata, 
      function(data){ 
    //Reset Form 
$('#myform')[0].reset(); 
fetchRowCount(); 
    }); 

    return false; 
}); 
}); 
//Fetch data from server 
function fetchRowCount() { 
    $.ajax({ 
        url: 'server2.php', 
        dataType: "json", 
        success: function (data) { 
$("#rows").html(data.rows); 
$("#min").html(data.min); 
$("#max").html(data.max); 
$("#mean").html(data.total); 
$("#last").html(data.last_entry); 

//Show gage once json is receved from server 

      var gage = new JustGage({ 
      id: "gauge", 
      value: data.total, 
      min: data.min, 
      max: data.max, 
      title: "Sample Data" 

     }); 
    $("#gauge").fadeIn(slow); 

        } 

    }); 

} 
</script> 

The html form 

<form class="form-inline" action="" id="myform" form="" method="post"> 

<!-- Text input--> 
<div class="form-group"> 
    <label class="col-md-4 control-label" for="bill_cost"></label> 
    <div class="col-md-8"> 
    <input id="bill_cost" name="bill_cost" type="text" placeholder="Bill Cost" class="form-control input-lg" required> 

<select id="utility_type" name="utility_type" class="form-control input-lg" required/> 
<option value="" >Energy Type</option> 
     <option value="Electric">Electric</option> 
     <option value="Gas">Gas</option> 
     <option value="Gas &amp; Electric Combo">Gas &amp; Electric Combo</option> 
    </select> 
    </div> 
</div> 

    </div> 
</div> 
<!-- Button --> 
<div class="form-group"> 
    <label class="col-md-4 control-label" for="submit1"></label> 
    <div class="col-md-4"> 
    <button id="submitButtonId" name="submit1" class="btn btn-primary btn-xl">Submit</button> 
    </div> 
</div> 

</form> 
+0

Können Sie eine bootply schaffen, damit wir sie in Aktion –

+0

Beitrag alle sehen von deinem code .. form, übermittle knopf, etc .. – ZimSystem

Antwort

2

Das erforderliche Attribut bedeutet, dass die Eingabetyp gefüllt werden muss, bevor Sie einreichen deine Form. Sie verwenden hier kein Formular-Tag, daher ist das erforderliche Attribut bedeutungslos.

0
<!-- Text input--> 
<div class="form-group"> 
    <label class="col-md-4 control-label" for="bill_cost"></label> 
    <div class="col-md-8"> 
    <form method="POST"> 
    <input id="bill_cost" name="bill_cost" type="text" placeholder="Bill Cost" class="form-control input-lg" required> 
</form> 
    </div> 
</div> 

erforderliche Attribut wird nur mit einreichen arbeiten Taste

ersetzen:

<button id="submitButtonId" name="submit1" class="btn btn-primary btn-xl">Submit</button> 

Mit

<input type="submit" id="submitButtonId" name="submit1" class="btn btn-primary btn-xl" value="Submit"> 
+0

Ich habe die angehängt Ganze funktioniert wie erwartet in Bootply, aber nicht auf meiner Seite. – JulianJ

+0

In Ihrem Code gibt es keine Schaltfläche zum Senden, Sie verwenden Button-Tag anstelle von senden – Nabeel

+0

Ich habe meine Antwort aktualisiert, werfen Sie einen Blick – Nabeel

Verwandte Themen