javascript – Include a .php page depending on the option selected in a drop down list


I am making a web application and I would like to include a different .php page for each option in the select . I tried include and require but it still doesn't work for me.

I have tried to do this, but it doesn't work for me:

   <select id="idioma" name="idioma">
              <option action="<?php require ('../Vista/lang/lang_es.php'); ?>" value="es" selected="selected">Español</option>
              <option action="<?php require ( '../Vista/lang/lang_en.php'); ?>" value="en">Inglés</option>

How could I fix it?


What you are trying to do is not feasible since you are on the client side.

I can think of that way to do it:

Through a post



if(isset($_POST['idioma']) && array_key_exists($_POST['idioma'], $includes)) :

<form id="selection_form" action="" method="post">
    <select name="idioma" id="idioma">
    <option value ="es">Español</option>
    <option value ="en">Inglés</option>
    <input type="submit" name="idioma_submit" value="GET FILE">
Scroll to Top