Page 1 of 1
Clear form field
Posted: Wed Apr 06, 2022 10:49 pm
by petejos
Hi Pablo,
I am using Version 15. I want to clear only few fields in my form when a selection is selected? For example when the user select "No", then I want information in fields 1 and 2 only to be cleared. Please help me. Thanks.
Re: Clear form field
Posted: Wed Apr 06, 2022 11:52 pm
by BaconFries
This will require a custom script such as javascript. Please note WB15 is no longer supported....
Re: Clear form field
Posted: Thu Apr 07, 2022 6:00 am
by GrahamW
here is some basic code to work with and amend to your form, this code will clear only fields 1 and 3
Code: Select all
<html>
<body>
<div>
<input type="text" id="1" size="5"/>
</div>
<div>
<input type="text" id="2" size="5"/>
</div>
<div>
<input type="text" id="3" size="5"/>
</div>
<div>
<input type="button" onclick="clearFields()" value="No">
</div>
<script type="text/javascript">
function clearFields() {
document.getElementById("1").value=""
document.getElementById("3").value=""
}
</script>
</body>
</html>
Graham
Re: Clear form field
Posted: Thu Apr 07, 2022 8:30 am
by Joe_120
Here is a code snippet that uses the value of the "No" select (which is 2) to hide all selected inputs. For each label and field you want to hide give it a class of no in item properties. Paste the following in a html frame and set frame type to
Before </body>
Code: Select all
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$('select').change(function () {
if($(this).val() === '2') {
$('.no').hide();
}
else {
$('.no').show();
}
});
</script>
Re: Clear form field
Posted: Fri Apr 08, 2022 11:19 am
by petejos
GrahamW wrote: ↑Thu Apr 07, 2022 6:00 am
here is some basic code to work with and amend to your form, this code will clear only fields 1 and 3
Code: Select all
<html>
<body>
<div>
<input type="text" id="1" size="5"/>
</div>
<div>
<input type="text" id="2" size="5"/>
</div>
<div>
<input type="text" id="3" size="5"/>
</div>
<div>
<input type="button" onclick="clearFields()" value="No">
</div>
<script type="text/javascript">
function clearFields() {
document.getElementById("1").value=""
document.getElementById("3").value=""
}
</script>
</body>
</html>
Graham
Thanks a lot Graham.
Re: Clear form field
Posted: Fri Apr 08, 2022 11:19 am
by petejos
Joe_120 wrote: ↑Thu Apr 07, 2022 8:30 am
Here is a code snippet that uses the value of the "No" select (which is 2) to hide all selected inputs. For each label and field you want to hide give it a class of no in item properties. Paste the following in a html frame and set frame type to
Before </body>
Code: Select all
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$('select').change(function () {
if($(this).val() === '2') {
$('.no').hide();
}
else {
$('.no').show();
}
});
</script>
thanks a lot Joe