Amigos estou apanhando em um JS aqui.
Seguinte : criei uma imagem, quero clicar nesta imagem e, através de um JS, ele colorir um TD.
Acontece que, ao clicar nesta imagem, o form esta sendo SUBMITADO !!!
Num sei o que pode ser !
Meu JSP :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="/WEB-INF/tld/fmt.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cadastro de Associados</title>
<link href="<c:url value="/css/estilo.css"/>" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #FFFFEA;
}
-->
</style>
<script type="text/javascript">
function mostrar(acao){
if (acao=='comercial'){
document.getElementById('comercio').style.bgcolor="#FBF8B7";
}
}
function enviar(acao){
document.forms[0].acao.value = acao;
if (document.forms[0].acao.value=='pesquisar'){
document.forms[0].submit();
}
else {
if (verifica()){
document.forms[0].submit();
}
else{
return false;
}
}
}
function verifica(){
if(document.forms[0].descricao.value==""){
alert("O Campo \"Descrição\" está em branco!");
return false;
}
if((document.forms[0].id.value=="") && (document.forms[0].acao.value == 'excluir')){
alert("Sem dados para Excluir!");
return false;
}
return true;
}
</script>
</head>
<body>
<form name="cadFuncao" action ="${pageContext.request.contextPath}/SocioSL" method="post">
<input type="hidden" name="acao">
<table width="100%" border="0">
<tr>
<td colspan=2 class="style3bold" align="center">Função</td>
</tr>
</table>
<table width="100%">
<tr>
<td width="25%"></td>
<td width="10%" bgcolor="#FBF8B7" align="center">
<input type="image" src="${pageContext.request.contextPath}/images/comercial32.gif" onClick="mostrar('comercial')"> </td>
<td width="25%"></td>
</tr>
<tr>
<td width="25%"></td>
<td id="comercio" width="10%" align="center" class="stylesmall">Comerciais</td>
<td width="25%"></td>
</tr>
<tr>
<td width="100%" height="20" colspan="3">
</tr>
</table>
<table width="100%">
<tr>
<td width="42%" ></td>
<td width="5%" align=center><input name="button" type="button" class="style3bold" onClick="return enviar('excluir')" value="Excluir"></td>
<td width="5%" align=center><input name="button" type="button" class="style3bold" onClick="return enviar('salvar')" value="Salvar"></td>
<td width="43%" ></td>
</tr>
</table>
<c:if test="${msgRequest!=null}">
<script>
alert('${msgRequest}')
</script>
</c:if>
</form>
</body>
</html>
Alguem pode me dar uma luz ?
ab
Bob
