In my site, I would like to have a text box where people could write a number and then from that number, a link was made, something like this:
If the user wrote 123 in the text box and clicked that button, which would open the link:
http://teste.com/Qualifier=123&Token =
or
If the user wrote 184 in the text box and clicked that button, which would open the link:
http://teste.com/Qualifier=184&Token =
______________________________
Is it possible? Which is the necessary code?
It's simple...
You just need change the method for GET and put on the action attribute the relative url.
Like this:
<form name="..." method="GET" action="your url">
And automatically the browser, will put the variable on the url.
Eu pensava que o fórum era inglês. Podemos continuar em português.
Acontece que o link que contém a variável não é no meu site. E como eu disse, gostaria de ter uma caixa de texto, onde o utilizador escrevesse a variável e depois ao clicar num botão, fosse levado ao url com a variável aplicada. Acho que isso requer um pouco de javascript, não?
É assim, podes sempre ir pelo jQuery, e usar uma função.
A resolução será qualquer coisa como:
$('#id_form').bind("submit", function(){
var url="http://teste.com/Qualifier=" + $('#id_da_caixa_de_texto').val() + "&Token=";
$('#id_do_elemento_a_href').attr('href', 'url');
});
ou
<form ..... onsubmit="changeURL('this.nome_do_campo_text.value')">
var url="";
function changeURL(url){
windows.location="http://teste.com/Qualifier=" + url + "?Token=";
}
Experimenta e depois dá feedback.
Cumprimentos.
Código:
<script>
var url="";
function changeURL(url){
windows.location="http://teste.com/Qualifier=" + url + "?Token=";
}
</script>
<form onsubmit="changeURL(url)">
<input type="text"/>
<input type="submit" value="Submit" />
</form>
Assim continua a não funcionar. Tens alguma ideia do que está a falhar? Na tag form deveria ser:
Código:
<form onsubmit="changeURL(url)" action="...">
Mas eu não sei o que escrever na parte "action".
No onsubmit, não podes pôr a variável url.
Tens de pôr como disse: onsubmit="changeURL('this.nome_do_input_text.value');"
No input text, tens de adicionar o name="qualquercoisa"
No action, podes deixar vazio ou então mete #.