Creating own shortcode – echoeing php variable based on JS variable

You can’t add logic for changing in that way. You need react on user “front-end” event with js.

Also this construction will work wrong:

 document.getElementById(\"form\").innerHTML = \"[contact-form-7 id=\"formId\"]\";

Will be always print [contact-form-7 id=\”formId\”], because js can’t do_shortcode function itself.

If you wanna make it simple(without ajax process) you need:

1) Print all forms with php and style “display: none;”

2) Add onchange event for select

3) On change options “show” needed form

Quick example how print forms:

 $formDivs="";
    forearch($ids_array as $i=>$id) {
      $formDivs .= do_shortcode("<div id=\"form_{$i}\" style="display: none;">[contact-form-7 id=\"{$id}\"]</div>");
    }