samedi 7 mars 2015

input required depending on button of form

To enter data into my database I created this form. The user can enter data add by clicking the add button the information is entered into the database. I am using required to force the user to enter text.


Now I added the edit and deleten button. Therefore the user shall select a record with the radio buttons provided. But with the required in the input elements it is only possible to do edit or delete if text is entered.


Is it somehow possible to assign the required to a certain button?





<form>
<table>
<tr>
<td>
<input type="radio" name="aName" />
</td>
<td>a</td>
<td>record</td>
</tr>
<td>
<input type="radio" name="aName" />
</td>
<td>another</td>
<td>record</td>
</tr>
<tr>
<td></td>
<td>
<input type="text" placeholder="enter" required >
</td>
<td>
<input type="text" placeholder="something" required>
</td>
</tr>



</table>
<input type="submit" value="add" formaction="form1.php" formmethod="post"/>

<input type="submit" value="delete" formaction="form2.php" formmethod="post"/>

<input type="submit" value="edit" formaction="form3.php" formmethod="post"/>
</form>



Aucun commentaire:

Enregistrer un commentaire