Forums
This topic is locked
Clearing self-referring form fields
Posted 01 Mar 2002 17:06:50
1
has voted
01 Mar 2002 17:06:50 Hank Tan-Tenn posted:
Hi,Pretty sure I'm not the first to run into this issue, but haven't been able to solve it:
I have a self-referring form that does server-side validation and colors red the incorrectly filled fields, keeping all the inputted data, of course.
Problem is, now the CLEAR button *apparently* does not work since it appears to just revert to the HTML field values now set to the inputted data.
How to create such a button that does work? (I use VBS.)
Thanx!
Replies
Replied 01 Mar 2002 23:28:55
01 Mar 2002 23:28:55 Myrck Willkomm replied:
Hi, try this client-side script instead =)
<script language="javascript">
function clearAll() {
for (j=0; j<document.form1.elements.length; j++) {
if (document.form1.elements[j].type == ("text" || "textarea" ) //for clearing text and textarea
document.form1.elements[j].value=''
if (document.form1.elements[j].type == "checkbox" //for clearing checkbox
document.form1.elements[j].checked = false;
if (document.form1.elements[j].type == "select-one" //for clearing list/menu
document.form1.elements[j].selectedIndex = 0;
}
}
</script>
<script language="javascript">
function clearAll() {
for (j=0; j<document.form1.elements.length; j++) {
if (document.form1.elements[j].type == ("text" || "textarea" ) //for clearing text and textarea
document.form1.elements[j].value=''
if (document.form1.elements[j].type == "checkbox" //for clearing checkbox
document.form1.elements[j].checked = false;
if (document.form1.elements[j].type == "select-one" //for clearing list/menu
document.form1.elements[j].selectedIndex = 0;
}
}
</script>
Replied 08 Mar 2002 04:12:50
08 Mar 2002 04:12:50 Hank Tan-Tenn replied:
I did try the Javascript, but wasn't able to achieve the desired effect, though it could be due to my being totally ignorant when it comes to deploying JS.
I did come up with a solution utilizing a button-like image that triggers Session.Abandon, and that did the job.
Anyway, thank you for replying!
PS: In my particular app Session.Abandon is acceptable, though I imagine it wouldn't be in other cases.
Edited by - akc on 08 Mar 2002 04:14:45
I did come up with a solution utilizing a button-like image that triggers Session.Abandon, and that did the job.
Anyway, thank you for replying!
PS: In my particular app Session.Abandon is acceptable, though I imagine it wouldn't be in other cases.
Edited by - akc on 08 Mar 2002 04:14:45