Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Links not working???

    I have a table where by in each cell there is a form with a link that submits the form.

    When I click the link however it does nothing!???

    When I have only one form it works fine. But once I have 2 or more forms it doesn't work?

    PS: I really do need to have a form for every link because I need to do a _POST on the links - and there's going to be many links as it's generated by PHP.

    PHP Code:
    <table >
    <
    thead >
        <
    tr>
            <
    th>
                
    Heading 1
            
    </th>
        </
    tr>
    </
    thead>
    <
    tbody>
        <
    tr>
            <
    td>
                <
    form name="submitForm" action="mylink.php" method="post">
                    <
    a href="javascript:document.submitForm.submit()">
                        
    First
                    
    </a>
                </
    form>
            </
    td>
        </
    tr>
        <
    tr>
            <
    td>
                <
    form name="submitForm" action="mylink.php" method="post">
                    <
    a href="javascript:document.submitForm.submit()">
                        
    Second
                    
    </a>
                </
    form>
            </
    td>
        </
    tr>
    </
    tbody>
    </
    table

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    forms do not have a 'name' attribute. They have an 'ID' attribute and id's a unique, can only be used once.

    Your using javascript to submit the form
    Code:
    <a href="javascript:document.submitForm.submit()">
    But you don't show your script. Why not just use the submit button?
    Code:
    <table >
    <thead >
        <tr>
            <th>
                Heading 1
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <form id="form1" action="mylink.php" method="post">
                <button type="submit" value="PUSH">Submit</button>First
                </form>
            </td>
        </tr>
        <tr>
            <td>
                <form id="form2" action="mylink.php" method="post">
                <button type="submit" value="PUSH">Submit</button>Second
                </form>
            </td>
        </tr>
    </tbody>
    </table>
    Will activate mylink.php, but wont do anything beyond that.
    Last edited by sunfighter; 10-12-2012 at 03:20 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •