Comment

Gpali

Another way in PHP

while (list($key, $value) = each(${"HTTP_".$REQUEST_METHOD."_VARS"})){

// Microsoft Internet Explorer don't likes <button></button> http://www.w3.org/TR/html4/interact/forms.html#buttons
// use for name="key" value="value" -> name="#key|value"

if(substr($key,0,1) == "#"){
$aKeyValue = iErepair(substr($key,1));
$key = $aKeyValue[0];
$value = $aKeyValue[1];
$$key = $value;

}
}

// -- IE Button Repair
function iErepair($varName){
$array = explode("|",$varName);
$key = $array[0];
$value = $array[1];
return $array;
}

Replies

Castwide

I've been experimenting with JavaScript solutions to the button problem, but this one trumps them all. Thanks.

Simon Bettison

This is by far the most elegent solution imo. It doeasnt rely on client-side functionality, is invisible to the user and still provides valid xhtml to boot.

If i could be so bold as to provide a slightly leaner alternative:

foreach ($_POST as $key => $val)
if(substr($key,0,1) == "#"){
$bits = explode("|",(substr($key,1)));
unset($_POST[$key]);
$_POST[$bits[0]] = $bits[1];
}

Us oldies hate typing ;)

Chad Lester

I found that this does not solve the problem stated on this blog. IE6 will still submit multiple name/value pairs even if the name is of the form #name|value.