DHTML/form javascript and MSIE
Expert: Andrew Hoffman - 6/24/2007
QuestionHi! I have a problem here, than I can't solve. The following code works fine on Mozilla-based browsers, but it shows alerts and does not work on MSIE. What could been happening? Thank you very much
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The form that does not submit in MSIE</title>
<script type='text/javascript'><!--
function darle(idsol,pest){
document.forms['form1'].action = 'otro.html' ;
document.forms['form1'].submit();
}
//-->
</script>
</head>
<body>
<form id='form1' name='form1' action='otherpage.php' method='post' enctype='multipart/form-data'>
<select class='inpt' id='alternativa' name='alternativa'>
<option value='0' selected='selected'>etapa</option>
<option value='1' >alternativa</option>
</select>
</form>
<table>
<tr><td style='background-color:#ffffff'>lista de tareas</td>
<td style='background-color:#9999ff'>
<a href='javascript:void(0)' onclick='darle(0,1)'>reconocimientos</a>
</td>
</tr>
<tr><td colspan='2'>the content
</td>
</tr>
</table>
</body>
</html>
AnswerReplace the javascript:void(0) with a # symbol, like this:
a href='javascript:void(0)' onclick='darle(0,1)'>reconocimientos</a>
<a href='#' onclick='darle(0,1)'>reconocimientos</a>
I believe IE6 was trying to execute the void(0) instead of the actual function you wanted to call. Seems to work now, though.
- Andrew