Comment

Robert Colburn

I use <button>s for management interfaces. So, the typical case is that I'm displaying several records in a table, and I need the button to identify which record to work on. This was requires no JavaScript, and works on all tested browsers.

This is in php, but it's pretty easy to port to something else.

// Example Form Code Before
foreach($records as $rec)
//Display Fields
echo '<button type="submit" name="save" value="'.$rec['id'].'">S</button>';
echo '<button type="submit" name="del" value="'.$rec['id'].'">X</button>';

// Example Form Code After
foreach($records as $rec){
//Display Fields
echo '<button type="submit" name="save'.$rec['id'].'">S</button>';
echo '<button type="submit" name="del'.$rec['id'].'">X</button>';

//---------------

// Example Processing Code Before
if(isset($_REQUEST['del']){
$rec = $_REQUEST['del'];
//remove code
}

// Example Processing Code After
if(isset($_REQUEST['del']){
foreach($_REQUEST['del'] as $rec){
//remove code
}
}