I have two radio buttons in a wordpress file. I have two contact-form-7 shortcodes and want to execute one if the radio is clicked “Yes” and the other if the radio button is “No”. I am willing to use ajax as i don’t want the page to reload but have no idea how to use it. It will be great if you could guide me.

Example HTML:

<input type=radio name=radio value=yes/>
<input type=radio name=radio value=no/>

<script>
if(radio==yes){
call_php_shortcode1();
}elseid(radio == no){
call_php_shortcode2();
}
</script>

Read more here: Perform PHP function on radio button click, WordPress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: