Ir para conteúdo
Fórum Script Brasil
  • 0

(RESOLVIDO) 3 select -> ir pra página em outra aba


Aléx Müller

Pergunta

Pessoal, dei uma olhada aqui e não encontrei nenhuma resposta. tenho um select q chama o segundo q chama o terceiro. tudo funcionando, mas abre no iframe onde encontra-se a referencia da página que tem o script. gostaria de ao selecionar o terceiro select, ele encaminhasse a página em nova aba (tipo target="_blank), mas não consegui nada.

Vou deixar o código aqui.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="content-language" content="en">
    <title>Seleção dos Cursos</title>

    <style type="text/css">
        html, body, form {
            padding: 0px;
            margin: 0px;
        }
        body {
            margin: 1em;
            font-family: Verdana, Arial, Helvetica, sans-serif;
        }
    </style>

    &lt;script type="text/javascript">
    <!--

        function loadSelectElement(selObjId, options) {
            var selObj = document.getElementById(selObjId);

            // clear the target select element apart from the "select your..." option
            selObj.options.length = 1;

            // copy options from array of [value, pair] arrays to select box
            // IE doesn't work if you use the DOM-standard method, however...
            if (typeof(window.clientInformation) != 'undefined') {
                // IE doesn't take the second "before" parameter...
                for (var loop=0; loop<options.length; loop++) selObj.add(new Option(options[loop][1], options[loop][0]));
            } else {
                for (var loop=0; loop<options.length; loop++) selObj.add(new Option(options[loop][1], options[loop][0]), null);
            }
        } // fecha função acima

        function madeSelection(selObj) {
            var selectedValue = selObj.options[selObj.selectedIndex].value;
            var selectedText = selObj.options[selObj.selectedIndex].text;
            if (selectedValue == '--') return;

            if (selObj.name == 'select01') {
                document.getElementById('select02Container').style.display = 'block';
                document.getElementById('select02').options[0].text = 'Selecione a Formação ';//+ selectedText.toLowerCase();

                switch(selectedValue) {
                    case 'campus_001':
                        loadSelectElement('select02', [
                            ['001_teci', 'Técnico Integrado'],
                            ['001_tecs', 'Técnico Subsequente'],
                            ['001_grat', 'Graduação - Tecnologia'],
                            ['001_espe', 'Especialização - Lato Sensu'],
                            ['001_mest', 'Mestrado - Stricto Sensu']
                        ]);
                        return;
                    case 'campus_002':
                        loadSelectElement('select02', [
                            []
                        ]);
                        return;
                    
                }
            } //  if do select01

            if (selObj.name == 'select02') {
                document.getElementById('select03Container').style.display = 'block';
                document.getElementById('select03').options[0].text = 'Selecione um Curso ';//+ selectedText;

                switch(selectedValue) {
                    case '001_teci':
                        loadSelectElement('select03', [
                            ['com_content&view=article&id=1102', 'Edificações'],
                            ['', 'Eletônica'],
                            ['', 'Eletrotécnica'],
                            ['', 'Química'],
                            ['', 'Saneamento']
                        ]);
                        return;
                    case '001_mest':
                        loadSelectElement('select03', [
                            ['com_content&view=article&id=1102', 'Mecatrônica']
                        ]);
                        return;

                }
            } // if do select02
        } // fecha função acima
        function linkSelection(obj){ // esta função chamada no "select03" está no link:
            // http://forum.imasters.com.br/topic/345052-resolvido%26nbsp%3Bao-selecionar-uma-opcao-dentro-da-select-redireciona/
            var src = "http://www.ifsc.edu.br/index.php?option="+obj.value; 
            location.href = src;
        }
        // Todo o Script, exceto citado anteriormente está no link:
        // http://www.tek-tips.com/faqs.cfm?fid=6294
    //-->
    </script>
</head>

<body align="right" style="background-image: url('vazio.png'); background-repeat:inherit">

    <form name="myForm">
    <table>
    <tr>
    <td width="40px" align="left">
    &nbsp;
    </td>
    <td width="250px" align="left">
    &nbsp;
    </td>
    <td width="250px" align="left">
    &nbsp;
    </td>
    <td width="250px" align="left">
        <select name="select01" id="select01" onchange="madeSelection(this);">
            <option value="--">Selecione um Campus</option>
            <option value="type_cat">Cat</option>
            <option value="type_dog">Dog</option>
            <option value="campus_001">Floripa</option>
            <option value="campus_002">São José</option>
        </select>
    </td>
    </tr>
    <tr>
    <td width="40px" align="left">
    &nbsp;
    </td>
    <td width="250px" align="left">
    &nbsp;
    </td>
    <td width="250px" align="left">
        <div id="select02Container" style="margin-top:1em; display:none;">
            <select name="select02" id="select02" onchange="madeSelection(this);">
                <option value="--">Selecione a Formação</option>
            </select>
        </div>
    </td>
    <td width="250px" align="left">
        <div id="select03Container" style="margin-top:1em; display:none;">
            <select name="select03" id="select03" onchange="linkSelection(this);"> 
                <option value="--">Selecione um Curso</option>
            </select>
        </div>
    </td>
    </tr>
    </table>
    </form>
</body>
</html>

Agradeço desde já quarquer ajuda.

Grato,

Aléx Müller.

Editado por Aléx Müller
Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Pessoal, obrigado pela atenção.

Não consegui descobrir o q deu problema ou o q poderia ser feito pra resolver a situação deste script.

Se alguém quiser tentar descobrir fica a vontade, farei isso assim q sobrar tempo, a título de estudo.

Pesquisei e encontrei uma outra solução, q ao selecionar o terceiro select, ele abre uma página (link). Ele abria na mesma página, mas consegui fazer abrir em outra (ao estilo target="_blank" ). Vejam o código abaixo:

<FORM name="isc">
<table border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td nowrap height="11"> &nbsp;
  
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>---Select1-------------</option>
<option>Webmaster Sites</option>
<option>News Sites</option>
</select>
  
<select name="stage2" size="1" onChange="redirect1(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select2--------------</option>
<option value=" " selected>---Select2--------------</option>
</select>
  
<select name="stage3" size="1" onChange="redirect2(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select3----------------</option>
<option value=" " selected>---Select3----------------</option>
</select>
  
<script>
/*
Triple Combo Script Credit
By Hamid Cheheltani/ JavaScript Kit (http://www.javascriptkit.com)
Visit http://javascriptkit.com for this and over 400+ other scripts
*/
var groups=document.isc.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group[i]=new Array()
  
group[0][0]=new Option("---Select2---"," ");
  
group[1][0]=new Option("Now Select This One"," ");
group[1][1]=new Option("JavaScript","47");
group[1][2]=new Option("DHTML","46");
group[1][3]=new Option("CGI","45");
  
group[2][0]=new Option("Now Select This One"," ");
group[2][1]=new Option("General News","115");
group[2][2]=new Option("Technology News","116");
  
var temp=document.isc.stage2
  
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
redirect1(0)
}
  
var secondGroups=document.isc.stage2.options.length
var secondGroup=new Array(groups)
for (i=0; i<groups; i++) {
secondGroup[i]=new Array(group[i].length)
for (j=0; j<group[i].length; j++) {
secondGroup[i][j]=new Array() }}
  
secondGroup[0][0][0]=new Option("---Select 3---"," ");
secondGroup[1][0][0]=new Option("---Select 3---"," ");
secondGroup[1][1][0]=new Option("Now Select This One"," ");
secondGroup[1][1][1]=new Option("JavaScript Kit","http://javascriptkit.com");
secondGroup[1][1][2]=new Option("JavaScript for the non programmer","http://webteacher.com/javascript/");
secondGroup[1][1][3]=new Option("Java-Scripts.net","http://java-scripts.net");
  
secondGroup[1][2][0]=new Option("Now Select This One"," ");
secondGroup[1][2][1]=new Option("Dynamic Drive","http://www.dynamicdrive.com");
secondGroup[1][2][2]=new Option("Beginner\'s Guide to DHTML","http://www.geocities.com/ResearchTriangle/Facility/4490/");
secondGroup[1][2][3]=new Option("Web Coder","http://webcoder.com/");
  
secondGroup[1][3][0]=new Option("Now Select This One"," ");
secondGroup[1][3][1]=new Option("CGI Resources","http://www.cgi-resources.com");
secondGroup[1][3][2]=new Option("Ada\'s Intro to CGI","http://adashimar.hypermart.net/");
  
secondGroup[2][0][0]=new Option("---Select 3---"," ");
secondGroup[2][1][0]=new Option("Now Select This One"," ");
secondGroup[2][1][1]=new Option("CNN","http://www.cnn.com");
secondGroup[2][1][2]=new Option("MSNBC","http://www.msnbc.com");
secondGroup[2][1][3]=new Option("ABC News","http://www.abcnews.com");
  
secondGroup[2][2][0]=new Option("Now Select A Page"," ");
secondGroup[2][2][1]=new Option("News.com","http://www.news.com");
secondGroup[2][2][2]=new Option("Wired","http://www.wired.com");
  
var temp1=document.isc.stage3
function redirect1(y){
for (m=temp1.options.length-1;m>0;m--)
temp1.options[m]=null
for (i=0;i<secondGroup[document.isc.example.options.selectedIndex][y].length;i++){
temp1.options[i]=new Option(secondGroup[document.isc.example.options.selectedIndex][y][i].text,secondGroup[document.isc.example.options.selectedIndex][y][i].value)
}
temp1.options[0].selected=true
}
  
function redirect2(z){
//window.location=temp1[z].value (parte original, removi e inseri a linha abaixo para abrir em nova janela)
window.open(temp1[z].value)
}
</script>
  
</td>
</tr>
</table>
</FORM>

Valeu pessoal!

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...