So you can analyze the Jsfiddle in your question, the forms for each tab are inside a iframe
. Therefore, in the function dealing with the change of tab, you should apply the following code:
// localizar a iFrame
var minhaFrame = document.getElementById( iframeID );
// localizar o conteudo da iframe
var minhaFrameDoc = minhaFrame.contentDocument || minhaFrame.contentWindow.document;
// localizar o formulário dentro da iframe pelo ID do formulario
var meuFormulario = minhaFrameDoc.getElementById( formID );
// repor formulário a vazio conforme resposta do @Sergio
meuFormulario.reset();
Your job Alter()
will stay:
function Alter(menu,conteudo)
{
for (i=0;i<arAbas.length;i++)
{
m = document.getElementById(arAbas[i].menu);
m.className = 'menu';
c = document.getElementById(arAbas[i].conteudo)
c.style.display = 'none';
}
m = document.getElementById(menu)
m.className = 'menu-sel';
c = document.getElementById(conteudo)
c.style.display = '';
var minhaFrame = c.getElementById( iframeID );
var minhaFrameDoc = minhaFrame.contentDocument || minhaFrame.contentWindow.document;
var meuFormulario = minhaFrameDoc.getElementById( formID );
// repor formulário a vazio conforme resposta do @Sergio
meuFormulario.reset();
}
For this to work, you must have one id
unique in each iframe
as well as a id
unique in each form:
Iframe
<table border="0" width="50%">
<tr>
<td>
<iframe id="iframeID" style="border-radius:20px;" scrolling="no" src="../sai_cada_usua/sai_frm_incl_usua.php" width="830" height="310" >
</iframe>
</td>
</tr>
</table>
Form
<form name="sai_frm_incl_usua1" id="formID" action="sai_incl_usua" method="POST" autocomplete="off" onsubmit="return f_veri_dados();">
<!-- conteúdo do formulário -->
</form>
This way, whenever the user clicks to change tab, the form that will be presented will be cleaned via Javascript, being thus without anything filled in the fields of the same.
Could explain a little more?
– Ronny Amarante
@Ronnyamarante my doubt is to enter the page and delete the filled fields (in my case the user changes menu and the data continues)
– Isaias
This must be happening if you use inputs with the same name.
– Marcelo Aymone