Notifications
Clear all

Sponsored test

1 Posts
1 Users
0 Reactions
237 Views
Posts: 5
Topic starter
(@djonz)
Active Member
Joined: 6 months ago
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Anket</title>
    <style>
        .hidden {
            display: none;
        }
        .result {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h1>Anket</h1>
    <form id="anketForm">
        <label for="isim">İsim:</label>
        <input type="text" id="isim" name="isim" required>
        <br><br>
        <label for="evet">Evet</label>
        <input type="radio" id="evet" name="secim" value="Evet" required>
        <label for="hayir">Hayır</label>
        <input type="radio" id="hayir" name="secim" value="Hayır" required>
        <br><br>
        <button type="submit">Gönder</button>
    </form>

    <div id="sonuc" class="hidden result">
        <h2>Anket Sonuçları</h2>
        <ul id="sonucListesi"></ul>
    </div>

    <script>
        document.getElementById('anketForm').addEventListener('submit', function(event) {
            event.preventDefault();
            
            const isim = document.getElementById('isim').value;
            const secim = document.querySelector('input[name="secim"]:checked').value;

            const sonucListesi = document.getElementById('sonucListesi');
            const yeniSonuc = document.createElement('li');
            yeniSonuc.textContent = `${isim}: ${secim}`;
            sonucListesi.appendChild(yeniSonuc);

            document.getElementById('sonuc').classList.remove('hidden');

            document.getElementById('anketForm').reset();
        });
    </script>
</body>
</html>
Share: