Clear form field

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
petejos
 
 
Posts: 155
Joined: Wed Aug 22, 2012 11:43 am

Clear form field

Post 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.
User avatar
BaconFries
 
 
Posts: 5642
Joined: Thu Aug 16, 2007 7:32 pm

Re: Clear form field

Post by BaconFries »

This will require a custom script such as javascript. Please note WB15 is no longer supported....
GrahamW
 
 
Posts: 238
Joined: Sat Jul 08, 2017 5:02 am

Re: Clear form field

Post 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
Last edited by GrahamW on Fri Apr 08, 2022 4:00 am, edited 1 time in total.
Joe_120
 
 
Posts: 30
Joined: Fri May 21, 2021 3:10 pm
Location: Cornwall

Re: Clear form field

Post 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>
If it wasn't for bad luck, I'd have no luck at all.
petejos
 
 
Posts: 155
Joined: Wed Aug 22, 2012 11:43 am

Re: Clear form field

Post 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.
petejos
 
 
Posts: 155
Joined: Wed Aug 22, 2012 11:43 am

Re: Clear form field

Post 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
Post Reply