How to open pages within an iframe conditioned by an option? [closed]

0

Good morning. I have a field type select and I want to do that based on the results selected in it, I open a page inside an iframe obviously conditioned by the select since it can open 4 different options.

                   one         two         3         4

// this is where the page that is selected in the select should open.

I hope somebody can help me ..

Greetings.

    
asked by Juan de Sergo 07.09.2017 в 20:42
source

1 answer

1

If you use Bootstrap, you use jQuery. If you use jQuery, you can simply define a <div> where to display the content you want if you need to use a iframe .

To achieve this you should only define your div:

<div id="show"></div>

and with jQuery use the load :

function
<script>
    $("#option").on("change", function(){
        //A continuación tomamos el valor del select (option) y elegimos qué mostrar
        switch($(this).val()){
            case "1":
                $("#show").load("/pagina1.php");
            break;
            case "2":
                $("#show").load("/pagina2.php");
            break;
            case "3":
                $("#show").load("/pagina3.php");
            break;
            case "4":
                $("#show").load("/pagina4.php");
            break;
        }
    });
</script>

You can even be more specific and define what section of the page you want to upload:

$("#show").load("/pagina2.php body");

and define some action for when the loading of the document ends:

$("#show").load("/pagina2.php form", function(){
    $("#inputDePagina2").focus();
});
    
answered by 07.09.2017 в 21:22