Cómo llamar a una función JS usando el evento OnClick
Estoy tratando de llamar a mi función JS que agregué en el encabezado. Por favor, a continuación encontrará el código que muestra el escenario de mi problema. Nota: No tengo acceso al cuerpo en mi aplicación. Cada vez que hago clic en el elemento conid="Save"
solo llamaf1()
pero nofun()
. ¿Cómo puedo hacer que llame incluso a mifun()
? Por favor ayuda.
<!DOCTYPE html>
<html>
<head>
<script>
document.getElementById("Save").onclick = function fun()
{
alert("hello");
//validation code to see State field is mandatory.
}
function f1()
{
alert("f1 called");
//form validation that recalls the page showing with supplied inputs.
}
</script>
</head>
<body>
<form name="form1" id="form1" method="post">
State:
<select id="state ID">
<option></option>
<option value="ap">ap</option>
<option value="bp">bp</option>
</select>
</form>
<table><tr><td id="Save" onclick="f1()">click</td></tr></table>
</body>
</html>