andredecotia 8 de fev. de 2011
Pior que parece ser tão fácil rs …
Granella 8 de fev. de 2011
Pior que é :lol:
& lt ; body onload = "document.getElementsByName('text2').value = trataURL();" & gt ;
andredecotia 8 de fev. de 2011
Puxa, fiz os testes mas continua não funcionando... Chega vazio na action daí da NumberFormatException...
<title></title>
<script language= "javascript" >
function trataURL(){
url = window.location;
url = url.toString();
url = url.split("?");
return url[1];
}
</script>
</head>
<body onload= "document.getElementsByName('text2').value = trataURL();" >
<h2> Passo 2 de 3</h2><br />
<form name= "form1" action= "CampoFornecedorServlet" method= "post" >
<table border= "1" >
<tr>
<td><br /><br /> Fornecedor: <input type= "text" name= "text1" /><br /><br /> </td>
<td><input type= "hidden" name= "text2" /></td>
</tr>
</table>
<input type= "submit" value= "Busca Arquivo Epub" /><br />
</form>
</body>
andredecotia 8 de fev. de 2011
Desta forma também não funcionou:
<script language= "javascript" >
function trataURL(){
url = window.location;
url = url.toString();
url = url.split("?");
document.getElementById('text2_1').value = url[1];
}
</script>
</head>
<body>
<h2> Passo 2 de 3</h2><br />
<form name= "form1" action= "CampoFornecedorServlet" method= "post" >
<table border= "1" >
<tr>
<td><br /><br /> Fornecedor: <input type= "text" name= "text1" /><br /><br /> </td>
<td><input type= "hidden" name= "text2" id= "text2_1" /></td>
</tr>
</table>
<input type= "submit" value= "Busca Arquivo Epub" /><br />
</form>
andredecotia 8 de fev. de 2011
Granella:
Pior que é :lol:
<body onload="document.getElementsByName('text2').value = trataURL();">
Puxa fiz um outro teste, funciona, mas só no IE…
Conhece alguma maneira de deixar multi-plataforma?
Granella 8 de fev. de 2011
assim deve funcionar, testei no Chrome:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function trataURL(frm) {
url = window.location;
url = url.toString();
url = url.split("?");
frm.text2.value = url[1];
}
</script>
</head>
<body>
<h2>Passo 2 de 3</h2><br />
<form name="form1" action="Teste" method="post" onsubmit="trataURL(this)">
<table border="1">
<tr>
<td><br /><br /> Fornecedor: <input type="text" name="text1" /><br /><br /></td>
<td><input type="hidden" name="text2" value="" /></td>
</tr>
</table>
<input type="submit" value="Busca Arquivo Epub" /><br />
</form>
</body>
</html>
febeckers 8 de fev. de 2011
Granella:
assim deve funcionar, testei no Chrome:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function trataURL(frm) {
url = window.location;
url = url.toString();
url = url.split("?");
frm.text2.value = url[1];
}
</script>
</head>
<body>
<h2>Passo 2 de 3</h2><br />
<form name="form1" action="Teste" method="post" onsubmit="trataURL(this)">
<table border="1">
<tr>
<td><br /><br /> Fornecedor: <input type="text" name="text1" /><br /><br /></td>
<td><input type="hidden" name="text2" value="" /></td>
</tr>
</table>
<input type="submit" value="Busca Arquivo Epub" /><br />
</form>
</body>
</html>
Teoricamente deve funcionar. Pois a função será executada quando você enviar o formulário. O teu exemplo anterior não funcionava porque você chamava a função no abrir da página e o campo não tinha sito gerado ainda. O correto é chamar o JS depois de gerar o campo. Algo do tipo:
& lt ; input type = "hidden" name = "text2" value = "" /& gt ;
& lt ; script & gt ;
trataURL ();
& lt ; / script & gt ;
andredecotia 8 de fev. de 2011
febeckers:
Granella:
assim deve funcionar, testei no Chrome:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function trataURL(frm) {
url = window.location;
url = url.toString();
url = url.split("?");
frm.text2.value = url[1];
}
</script>
</head>
<body>
<h2>Passo 2 de 3</h2><br />
<form name="form1" action="Teste" method="post" onsubmit="trataURL(this)">
<table border="1">
<tr>
<td><br /><br /> Fornecedor: <input type="text" name="text1" /><br /><br /></td>
<td><input type="hidden" name="text2" value="" /></td>
</tr>
</table>
<input type="submit" value="Busca Arquivo Epub" /><br />
</form>
</body>
</html>
Teoricamente deve funcionar. Pois a função será executada quando você enviar o formulário. O teu exemplo anterior não funcionava porque você chamava a função no abrir da página e o campo não tinha sito gerado ainda. O correto é chamar o JS depois de gerar o campo. Algo do tipo:
& lt ; input type = "hidden" name = "text2" value = "" /& gt ;
& lt ; script & gt ;
trataURL ();
& lt ; / script & gt ;
febeckers, vc é dez!
valeu abraços,
febeckers 8 de fev. de 2011
andredecotia 9 de fev. de 2011
Granella valeu…