Chetan
Chetan

Reputation: 162

Contact form 7 add textbox on radiobutton checked

I have two radio button in my form (Radio 1, Radio 2)

When i am click on Radio 2 at that time one textbox is create in form.

I have used contact form 7

Thanks,

Upvotes: 1

Views: 9914

Answers (2)

R.K.Bhardwaj
R.K.Bhardwaj

Reputation: 2192

hi put this html into your contact form above send button

 <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>radio1  
        <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>radio2
        <TEXTAREA id="area" style="display: none;" NAME="data" ROWS=10 COLS=50></TEXTAREA> 

then put script into themes header or footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>     
<script type="text/javascript">
            function show() { document.getElementById('area').style.display = 'block'; }
            function hide() { document.getElementById('area').style.display = 'none'; }
          </script>

        function show() { document.getElementById('area').style.display = 'block'; }
        function hide() { document.getElementById('area').style.display = 'none'; }
 
 <form name="radios">
        <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>Radio 1
        <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>Radio 2  
        <TEXTAREA id="area" style="display: none;" NAME="data" ROWS=10 COLS=50></TEXTAREA>   
      </form>

Upvotes: 0

Ahmed Ginani
Ahmed Ginani

Reputation: 6650

Yes, You can show textbox in your form on radio button checked by using Conditional Fields for Contact Form 7 plugin.

Please follow this link. It provides setting to hide or show particular field on select another field by using condition logic.

It should work for you as you needed.

Thanks.

Upvotes: 3

Related Questions