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>
<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">
 
</td>
<td width="250px" align="left">
 
</td>
<td width="250px" align="left">
 
</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">
 
</td>
<td width="250px" align="left">
 
</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>
Pergunta
Aléx Müller
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> <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">   </td> <td width="250px" align="left">   </td> <td width="250px" align="left">   </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">   </td> <td width="250px" align="left">   </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üllerLink para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados
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.