• 02-01-2023, 14:12:29
    #1
    <form id="surfbar" method="post" action="test">
    <input value="http://www.google.com/" class="input" name="page" type="text" id="maintextfield">
    <input class="boton" src="https://www.r10.net/images/surf_btn.png" value="Submit" alt="Submit" type="image">
    </form>
    İnput value içine yazılan yazıyı action içine nasıl yansıtırım
  • 02-01-2023, 14:20:03
    #2
    Merhaba! Eğer value değerini action öğesine yansıtmak istiyorsanız, formun submit olayı için bir işlev oluşturabilir ve bu işlev içinde form elementinin action özelliğini value değerine göre dinamik olarak değiştirebilirsiniz. Örneğin:

    function updateAction() { var form = document.getElementById("surfbar"); var input = document.getElementById("maintextfield"); form.action = input.value; }

    Bu işlevi formun submit olayına bir olay dinleyicisi ekleyerek çalıştırabilirsiniz:

    document.getElementById("surfbar").addEventListene r("submit", updateAction);

    Bu şekilde, form gönderildiğinde action özelliği value değerine göre dinamik olarak değiştirilecektir.
  • 02-01-2023, 14:20:53
    #3
    Roadhog adlı üyeden alıntı: mesajı görüntüle
    <form id="surfbar" method="post" action="test">
    <input value="http://www.google.com/" class="input" name="page" type="text" id="maintextfield">
    <input class="boton" src="https://www.r10.net/images/surf_btn.png" value="Submit" alt="Submit" type="image">
    </form>
    İnput value içine yazılan yazıyı action içine nasıl yansıtırım
    <html>
    <head>
    </head>
    <body>
    
    <form id="surfbar" method="post" action="test">
    <input value="http://www.google.com/" class="input" name="page" type="text" id="maintextfield">
    <input class="boton" src="https://www.r10.net/images/surf_btn.png" value="Submit" alt="Submit" type="image">
    </form>
    
    <script>
        const input = document.getElementById('maintextfield');
        const form = document.getElementById('surfbar');
        input.addEventListener('input', function (){
    form.setAttribute('action', input.value)
    });
    </script>
    </body>
    </html>