0

In the code below all submit and reset buttons works for all textboxes, however I want it to make it so that every button applies to the textbox one above it. I want one button to work for only one textbox.

<form name="email" action="mail.php" method="get">
        <table>
            <tbody>

                <tr><td>Ad:</td><td><input type="text" name="ad" size="20" maxlength="30" required></td></tr>
                <tr><td>Soyad:</td><td><input type="text" name="soyad" size="20" maxlength="30" required></td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td>email:</td><td><input type="email" name="email"></td></tr>
                <tr><td><input type="submit"></td><td><input type="reset"></td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td> <td></td> </td></tr>
                <tr><td>Web:</td><td><input type="url"></td></tr>
                <tr><td><input type="submit"></td><td><input type="reset"></td></tr>

            </tbody>
        </table>
    </form>

How can I do that?

  • You need to post that using `js` - start here: https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX – A. Meshu Nov 03 '21 at 09:47
  • @A.Meshu Isn't it possible by only using HTML ? It is a very simple thing. Just bind one button and textbox together thats it. Do I really have to know Javascript for this? – PhysicsEnginering Nov 03 '21 at 09:50
  • if you submit a field like you want the original page will restart. You can "hack" that with `php` or split your fields to different pages and redirect to that on every post - BUT that would be waste of time. – A. Meshu Nov 03 '21 at 09:54
  • When hitting submit all inputs inside the form will submit and the page will refresh. This is the expected behavior when you hit submit. If you want to change that (for example, send to the server a specific field without refreshing the page etc) - you need to use `javascript`. – A. Meshu Nov 03 '21 at 10:02
  • Putting them into seperate div does not work still buttons in different div affect textboxes in different div. – PhysicsEnginering Nov 03 '21 at 10:04
  • @A.Meshu Maybe I should put them into seperate forms then, yeah it worked. No need for javascript. – PhysicsEnginering Nov 03 '21 at 10:05

1 Answers1

0

For this I think you need submit the request through javascript Then you can able to controll the form and able to send exact data to server