Forum Moderators: open
<form>
Main Category [Another submit button (another form) here with value "change"]
Sub Category
<select>
.....
</select>
...
<input type="submit">
</form>
IE dont accept it, but FF works fine. How can I make it work in IE or how can I rewrite my form wherein I need a submit button (form) inside a form.
The two ways are first to make them two separate forms. If you use tables for layout, you can't nest them between rows, you have to have the forms fully contained within a cell or their own table:
<form>
<table>
</table>
</form>
<table>
<tr><td>
<form>
</form>
</td></tr>
</table>
If you can't make two forms, you can make program logic function based on which button was clicked by naming your buttons.
<form>
<input type="submit" name="action-a" value="Action A">
<input type="submit" name="action-b" value="Action B">
</form>
So whether you're using PHP, perl, whatever,
if (isset($_POST['action-a'])) {
// perform action a
}
else if (isset($_POST['action-b'])) {
// perform action b
}
else {
// Default action, which is likely to re-output the form
// with a message to select a button
}
If someone hits enter to submit the form "default action" is executed. Depending on the scenario, it may just be a duplicate of action A or B.
if (isset($_POST['action-a'])) {
// perform action a
}
else {
// Default action, which is B
}