<script src="//code.jquery.com/jquery-1.9.1.min.js"></script><form action="categoria/cidade" method="post" id="formImasters">
<div class='grupo'>
<select name='categoria' id='categoria'>
<option value='' selected>Categoria</option>
<option value='3' selected>Abrasivos, Ferramentas e Soldas</option>
<option value='4' selected>Acessórios de Moda</option>
<option value='5' selected>Agências</option>
<option value='6' selected>Agricultura e Pecuária</option>
<option value='7' selected>Agroindústria</option>
<option value='8' selected>Alimentos e Nutrições Especiais</option>
<option value='9' selected>Alimentos Prontos e Pré-prontos</option>
<option value='10' selected>Aluguel, Compra e Venda de Veículos</option>
<option value='11' selected>Animais - Criadores</option>
<option value='12' selected>Animais - Serviços</option>
<option value='13' selected>Animais Domésticos - Criadores</option>
<option value='14' selected>Aparelhos de Medição, Precisão e Controle</option>
<option value='15' selected>Aquecimento e Ventilação</option>
<option value='16' selected>Arame</option>
<option value='17' selected>Armações e Esquadrias</option>
<option value='18' selected>Armarinhos, Aviamentos</option>
<option value='19' selected>Armazenagem e Logística</option>
<option value='20' selected>Armazenagem e LogísticaArte e Cultura</option>
<option value='21' selected>Artigos</option>
<option value='22' selected>Artigos e Equipamentos</option>
<option value='23' selected>Artigos para Comércio</option>
<option value='24' selected>Artigos para Indústria</option>
<option value='25' selected>Artigos para Metal</option>
<option value='26' selected>Artigos para Proteção Individual</option>
<option value='27' selected>Balanças</option>
<option value='29' selected>Dentista</option>
<option value='28' selected>Pizzaria</option>
<option value='2' selected>Restaurantes</option>
</select>
</div>
<div class='grupo'>
<select name='cidade' id="cidade">
<option value='' selected>Cidade</option>
<option value='1' selected>Praia Grande</option>
<option value='3' selected>Santos</option>
<option value='2' selected>Vila Velha</option>
</select>
<input type='submit' name='submit' class='submit' value='OK'>
</div>
</form>
(function(){
$('.submit').on('click', function(e){
var t = $(this);
var form = $("#formImasters");
var base = "http://site.com.br/"; //deixe em branco, nao precisa preencher, se possivel remova essa variavel
var final = "";
var categoria = generateURL(form.find('#categoria').find(":selected").text());
var cidade = generateURL(form.find('#cidade').find(":selected").text());
final = base + categoria + "/" + cidade;
form.attr('action', final);
});
function generateURL(str) {
return removeAccents(str.toLowerCase().replace("- ", "").replace(/\s/g, "-").replace(",", ""));
}
function removeAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
strAccentsOut[y] = strAccents[y];
}
strAccentsOut = strAccentsOut.join('');
return strAccentsOut;
}
})();
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |