Jump to content

Combobox JS


Recommended Posts

Boas, precisava que depois da combobox ser seleccionada mantive-se na selecção.

<form action="" method="post" >
<select name="cb_tabelas" id="cb_tabelas" onchange="window.location = this.options[this.selectedIndex].value">

 <option value="0">--Selecionar Categoria--</option>
<option value="index.php?site=editar&id=1">Marcas</option>
<option value="index.php?site=editar&id=2">Produtos</option>
<option value="index.php?site=editar&id=3">Projectos</option>
<option value="index.php?site=editar&id=4">Promoções</option>
<option value="index.php?site=editar&id=5">Enventos</option>
<option value="index.php?site=editar&id=6">Nossas Marcas</option>

<input name="editar" type="button" value="Editar" />
Edited by apocsantos
Link to comment
Share on other sites

então a única solução é usar javascript

usando o seguinte código:


function getParameterByName(name) {
   name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
   var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
       results = regex.exec(location.search);
   return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

deverás registar a seguinte função a ser executada no momento que a página se encontra carregada

function setSelectValue() {
 var element = document.getElementById('cb_tabelas');
 element.value = getParameterByName('id');


IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.