ich mit php.I lernen jquery beginnen werde habe Form (die ich von Google kopiert)Wie der Wert der Textbox auf 0, wenn leer setzen, wenn Checkbox nicht
$('document').ready(function() {
$('.toggleswitch').bootstrapToggle();
$("#check1 .stars").click(function() {
$(this).attr("checked");
});
});
/****** Rating Starts *****/
@import url(http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
fieldset,
label {
margin: 0;
padding: 0;
}
body {
margin: 20px;
}
h1 {
font-size: 1.5em;
margin: 10px;
}
.rating {
border: none;
float: left;
}
.rating>input {
display: none;
}
.rating>label:before {
margin: 5px;
font-size: 1.25em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}
.rating>.half:before {
content: "\f089";
position: absolute;
}
.rating>label {
color: #ddd;
float: right;
}
.rating>input:checked~label,
.rating:not(:checked)>label:hover,
.rating:not(:checked)>label:hover~label {
color: #FFD700;
}
.rating>input:checked+label:hover,
.rating>input:checked~label:hover,
.rating>label:hover~input:checked~label,
.rating>input:checked~label:hover~label {
color: #FFED85;
}
/* Downloaded from http://devzone.co.in/ */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-toggle/2.2.2/js/bootstrap2-toggle.min.js"></script>
<form action="" method="POST" />
<fieldset id='check1' class="rating">
<input class="stars" type="radio" id="star_a-5" name="rating" value="5" />
<label class="full" for="star5" title="Awesome - 5 stars"></label>
<input class="stars" type="radio" id="star_a_5-half" name="rating" value="4.5" />
<label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
<input class="stars" type="radio" id="star_a-4" name="rating" value="4" />
<label class="full" for="star4" title="Pretty good - 4 stars"></label>
<input class="stars" type="radio" id="star_a_4-half" name="rating" value="3.5" />
<label class="half" for="star3half" title="Meh - 3.5 stars"></label>
<input class="stars" type="radio" id="star_a-3" name="rating" value="3" />
<label class="full" for="star3" title="Meh - 3 stars"></label>
<input class="stars" type="radio" id="star_a_3-half" name="rating" value="2.5" />
<label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
<input class="stars" type="radio" id="star2" name="rating" value="2" />
<label class="full" for="star2" title="Kinda bad - 2 stars"></label>
<input class="stars" type="radio" id="star1half" name="rating" value="1.5" />
<label class="half" for="star1half" title="Meh - 1.5 stars"></label>
<input class="stars" type="radio" id="star1" name="rating" value="1" />
<label class="full" for="star1" title="Sucks big time - 1 star"></label>
<input class="stars" type="radio" id="starhalf" name="rating" value="0.5" />
<label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
</fieldset>
<br>
<input type="submit" onclick="setValue()" name="btn_submit" value="submit" />
</div>
mit dieser PHP:
<?php
if(isset($_POST['btn_submit']))
{
echo '<pre>';
print_r($_POST);
}
?>
Diese Form fine.If funktioniert i-Sterne-Rate klicken und Absenden-Button habe ich eine Ausgabe wie
Array
(
[rating] => 1
[btn_submit] => submit
)
Und wenn ich wählen werde keine Bewertung Ausgabe wie sein
Array
(
[btn_submit] => submit
)
aber ich erwarte
Array
(
[rating] => 0
[btn_submit] => submit
)
Ich versuchte
function setValue()
{
var input = document.getElementById('check1');
if(input.value.length == '')
input.value = 0;
}
Wenn ich nicht bin klicken Sterne Rate Eingabefeld auf 0 gesetzt? Wie kann ich tun, wenn ich mehr Texteingabe wie check2 PRÜFUNG3Haben check4 mit jquery? Ich habe wollen, dass alle Eingabetextfeld gesetzt als 0, bevor Daten gesendet, wenn Bewertung mir nicht clicked.Please helfen ist? Als Anfänger vergeben Sie bitte, ob macht jede hatte Fehler
Wenn Sie keine Checkbox wird es nicht Wert des Servers bereitstellen Seite –
@PankajMakwana: Dann wie kann ich it..please mir helfen .. –
@teststack ich habe eine [Antwort] (https://stackoverflow.com/a/45079490/4939819) – Hassaan