Gdyby to było takie proste to bym i może "pojechał" na jakimś tutorialu, ale nawet nie mogę nic znaleźć i dlatego właśnie na forum pytam.
Próbowałem to zrobić w php, ale oczywiście nie działa i utknąłem w martwym punkcie.
Może znajdzie się jednak ktoś, kto się zna i mi pomoże.
Dodałem taki kod na początku strony:
Cały kod strony wygląda tak:
Próbowałem to zrobić w php, ale oczywiście nie działa i utknąłem w martwym punkcie.
Może znajdzie się jednak ktoś, kto się zna i mi pomoże.
Dodałem taki kod na początku strony:
Kod PHP:
<?php
$count = 0;
$count = $_POST['radio2'] + $_POST['radio3'] + $_POST['radio4'] + $_POST['checkbox1'] + $_POST['checkbox2'] + $_POST['checkbox3'];
if($count > 0)
echo "Suma: ";
?>
Cały kod strony wygląda tak:
Kod PHP:
<?php
$count = 0;
$count = $_POST['radio2'] + $_POST['radio3'] + $_POST['radio4'] + $_POST['checkbox1'] + $_POST['checkbox2'] + $_POST['checkbox3'];
if($count > 0)
echo "Suma:$count";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="WebSite PRO 4.3" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Reply-to" content="" />
<meta http-equiv="content-Language" content="pl" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="Author" content="" />
<meta name="robots" content="all" />
<style type="text/css"></style>
<title></title>
</head>
<body>
<form action="count.php" onreset="if (!confirm('Czy na pewno chcesz wyczyścicć cały formularz?')) return false">
<legend></legend>
<!-- brak opcji wyboru -->
<strong>1.</strong><br />
<label>1.1<input type="checkbox" id="01" name="checkbox1" value="50" disabled="disabled" checked="checked" /></label><br />
<!-- Dwie opcje wyboru, 2 x radio, wybor tylko jednej -->
<strong>2.</strong><br />
<label>2.1<input type="radio" id="02" name="radio2" value="50" /></label><br />
<label>2.2<input type="radio" id="03" name="radio2" value="10" checked="checked" /></label><br />
<!-- Cztery opcje wyboru, 4 x radio, wybor tylko jednej -->
<strong>3.</strong><br />
<label>3.1<input type="radio" id="04" name="radio3" value="20" checked="checked" /></label><br />
<label>3.2<input type="radio" id="05" name="radio3" value="40" /></label><br />
<label>3.3<input type="radio" id="06" name="radio3" value="70" /></label><br />
<label>3.4<input type="radio" id="07" name="radio3" value="120" /></label><br />
<!-- Cztery opcje wyboru, 4 x radio, wybor tylko jednej -->
<strong>4.</strong><br />
<label>4.1<input type="radio" id="08" name="radio4" value="20" checked="checked" /></label><br />
<label>4.2<input type="radio" id="09" name="radio4" value="20" /></label><br />
<label>4.3<input type="radio" id="10" name="radio4" value="30" /></label><br />
<label>4.4<input type="radio" id="11" name="radio4" value="50" /></label><br />
<!-- Dwa pola wyboru, 2 x checkbox, mozna wybrac dwa -->
<strong>5.</strong><br />
<label>5.1<input type="checkbox" id="12" name="checkbox2" value="50" /></label><br />
<label>5.2<input type="checkbox" id="13" name="checkbox3" value="50" /></label><br />
<!-- Button WYSLIJ -->
<input type="submit" value="Podlicz" /><br />
<!-- Button WYCZYSC, czysci zaznaczenia -->
<input type="reset" value="Wyczyść" /><br />
<label>Suma: <input type="text" name="nazwa" readonly="readonly" /></label><br />
</form>
</body>
</html>