I’ll try to be clear. I have a listbox with 3 entries in it, and when my entry number 2 is selected it makes a field, which is by default hidden, become visible.
Then after the form is submitted, the selected item stays in the listbox (already worked that out), but the field that became visible goes back to its default setting, hidden. I’d like it to stay visible, in case the submit didn’t pass the validation requirements or whatever other reason.
I know it has to be quite easy but I’m still getting used to HTML/PHP/Javascript.
If you guys need any code parts I’ll be more than happy to offer them. I just don’t want to post my full code for no reason, which is pretty messy and quite long.
Thanks in advance!
EDIT:
actually i just found it. thanks for the help, putted me on the right track
so heres the code, you just have to put this anywhere in the body tag.
this will do any action onload.
so as my code goes it will check if the id of my list box is the number 2, if it is its gonna do the actons in the IF statement.
looks for my fields and put them visible.
<script>
window.onload = function() {
if (document.getElementById("topic2").value=="2")
{
document.getElementById("Agence").style.visibility='Visible';
document.getElementById("agence_tittle").style.visibility='Visible';
}
}
</script>
is your form submit function refreshing the page or setting hidden fields/classes back to hidden?