I have a form that I am trying to create a link to insert a new record within a dynamic table I am able to accuratly do this with a form as below using a submit button

<tr>
    <form method="POST" action="<?php echo $editFormAction; ?>" name="submitOption" id="submitOption">
        <td class="tdInvisible"><?php echo $row_allQuestionOptionUser['optionKey']; ?><input name="optionKeyHidden" type="hidden" value=<?php echo $row_allQuestionOptionUser['optionKey']; ?> /></td>
        <td class="tdInvisible"><?php echo $row_allQuestionOptionUser['questionKey']; ?><input name="questionKeyHidden" type="hidden" value=<?php echo $row_allQuestionOptionUser['questionKey']; ?> /></td>
        <td class="tdInvisible"><?php echo $userKey; ?><input name="userKeyHidden" type="hidden" value=<?php echo $userKey; ?> /></td>
        <td><input name="test" type="submit" /></td>
    <input type="hidden" name="MM_insert" value="submitOption" />
    </form>
</tr>

but when I try to use the following code it only inserts with the value of the first record using the "javascript:document.forms[0].submit();"

<tr>
    <form method="POST" action="<?php echo $editFormAction; ?>" name="submitOption" id="submitOption">
        <td class="tdInvisible"><?php echo $row_allQuestionOptionUser['optionKey']; ?><input name="optionKeyHidden" type="hidden" value=<?php echo $row_allQuestionOptionUser['optionKey']; ?> /></td>
        <td class="tdInvisible"><?php echo $row_allQuestionOptionUser['questionKey']; ?><input name="questionKeyHidden" type="hidden" value=<?php echo $row_allQuestionOptionUser['questionKey']; ?> /></td>
        <td><a href="javascript:document.forms[0].submit();"><?php echo $row_allQuestionOptionUser['optionText']; ?></a></td>
        <td class="tdInvisible"><?php echo $userKey; ?><input name="userKeyHidden" type="hidden" value=<?php echo $userKey; ?> /></td>
    <input type="hidden" name="MM_insert" value="submitOption" />
    </form>
</tr>

Any help would be appreciated

I ended up just using the submit button, but passed the field value to the button value and used CSS to style to my desired effect

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.