[resolu]Lien a partir d'un input
Dernière réponse : dans Programmation
Bonjour a tous
alors j'ai cree une page avec un fram au milieux
dans cette fram il y a un input et un bouton
je voudrais que si par exemple dans le input le visiteur inscrit "w00w2" et valide par le bouton
que cette fram affiche la page w00w2 .
mais comment on fais pour cree un lien a partir d'un input ?
je sais pas si je suis tres clair !!
mais bon dit moi si vous avais pas comprit
alors j'ai cree une page avec un fram au milieux
dans cette fram il y a un input et un bouton
je voudrais que si par exemple dans le input le visiteur inscrit "w00w2" et valide par le bouton
que cette fram affiche la page w00w2 .
mais comment on fais pour cree un lien a partir d'un input ?
je sais pas si je suis tres clair !!
mais bon dit moi si vous avais pas comprit
Autres pages sur : resolu lien partir input
Lassé par la pub ? Créez un compte
déjà on dit (et écrit) fame...
ensuite, il suffit d'un javascript simple, en partant du principe que ton input s'appelle dest:
et dans ton html:
ensuite, il suffit d'un javascript simple, en partant du principe que ton input s'appelle dest:
<script type="text/javascript">
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
</script>
et dans ton html:
<form name="bla" method="post" onsubmit="return redirect();">
<input type="test" name="dest" id="dest" />
Bon sa marche pas ( ou peut-etre que sa vien de moi car je ne connais pas le javascript )
alors voila le code de ma frame :
Ps. mettre les code entre les balise fixed et /fixed aulieu de code et /code , plus simple pour les copier coller .
alors voila le code de ma frame :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//FR" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style1 {color: #000000}
.Style2 {color: #000000; font-weight: bold; }
-->
</style></head>
<script type="text/javascript">
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
</script>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<input type="test" name="dest" id="dest" />
<br />
<button ><img src="images/SJ168_L.jpg" height="129" width="166" /></button>
</form>
</p>
</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style1 {color: #000000}
.Style2 {color: #000000; font-weight: bold; }
-->
</style></head>
<script type="text/javascript">
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
</script>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<input type="test" name="dest" id="dest" />
<br />
<button ><img src="images/SJ168_L.jpg" height="129" width="166" /></button>
</form>
</p>
</p>
</body>
</html>
Ps. mettre les code entre les balise fixed et /fixed aulieu de code et /code , plus simple pour les copier coller .
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//FR" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style1 {color: #000000}
.Style2 {color: #000000; font-weight: bold; }
-->
</style></head>
<script type="text/javascript">
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
</script>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<input type="test" name="dest" id="dest" />
<br />
<button ><img src="images/SJ168_L.jpg" height="129" width="166" /></button>
</form>
</p>
</p>
</body>
</html>
1. Ca serait pas plutot <input type="text" id="dest" etc... /> ?
2. Au lieu de <button /> met un <input type="submit" etc.. /> pour declancher le handler de l'event onSubmit
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style1 {color: #000000}
.Style2 {color: #000000; font-weight: bold; }
-->
</style></head>
<script type="text/javascript">
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
</script>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<input type="test" name="dest" id="dest" />
<br />
<button ><img src="images/SJ168_L.jpg" height="129" width="166" /></button>
</form>
</p>
</p>
</body>
</html>
1. Ca serait pas plutot <input type="text" id="dest" etc... /> ?
2. Au lieu de <button /> met un <input type="submit" etc.. /> pour declancher le handler de l'event onSubmit
Marche toujours pas .
alors voici le nouveaux code source de la page
et voila le .js :
alors voici le nouveaux code source de la page
<script type="text/javascript" src="000.js"></script>
</head>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<div align="center">
<input type="text" name="dest" id="dest" />
<br />
<input type="submit" value="Entree"/>
</div>
</form>
<div align="center"><a href="javascript:alert('Gros Bouler en vue !');">Ne clique pas ici </a>
</div>
</body>
</html>
</head>
<body>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center" class="Style2"> </p>
<p align="center"><span class="Style1"><strong>Veuiller entrer votre</strong></span><span class="Style1"><strong>code </strong></span><strong>:</strong><br />
<form name="bla" method="post" onsubmit="return redirect();">
<div align="center">
<input type="text" name="dest" id="dest" />
<br />
<input type="submit" value="Entree"/>
</div>
</form>
<div align="center"><a href="javascript:alert('Gros Bouler en vue !');">Ne clique pas ici </a>
</div>
</body>
</html>
et voila le .js :
alert('Bonjour');
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
function redirect() {
dest = document.getElementById('dest').value;
document.location.href = dest+".html";
}
J'ai fini par trouvais !
voila le code final ( qui na rien avoir avec le premier )
et voila le .js
var t1 ="Page fermer" ;
if ( autorisation == 1)
{
function ouvrir()
{
location.href =document.formulaire.MotdePasse.value + '.html'
}
}
else
{
alert(t1) ;
}
Merci de votre aide quand meme
voila le code final ( qui na rien avoir avec le premier )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style2 {color: #000000; font-weight: bold; }
-->
</style>
<script type="text/javascript" src="000.js"></script>
</head>
<body>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<FORM NAME="formulaire">
<div align="center">
<p align="center"><strong>Veuiller entre votre code !</strong></p>
<INPUT NAME="MotdePasse" type="text">
<br />
<INPUT TYPE="BUTTON" Value="Valider" onClick="ouvrir()">
<br />
<br />
<a href="javascript:alert('Gros Bouler en vue !');">Ne clique pas ici </a>
<br />
</div>
</FORM>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body,td,th {
color: #0033FF;
}
body {
background-color: #FFFF00;
}
.Style2 {color: #000000; font-weight: bold; }
-->
</style>
<script type="text/javascript" src="000.js"></script>
</head>
<body>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<FORM NAME="formulaire">
<div align="center">
<p align="center"><strong>Veuiller entre votre code !</strong></p>
<INPUT NAME="MotdePasse" type="text">
<br />
<INPUT TYPE="BUTTON" Value="Valider" onClick="ouvrir()">
<br />
<br />
<a href="javascript:alert('Gros Bouler en vue !');">Ne clique pas ici </a>
<br />
</div>
</FORM>
</body>
</html>
et voila le .js
var t1 ="Page fermer" ;
if ( autorisation == 1)
{
function ouvrir()
{
location.href =document.formulaire.MotdePasse.value + '.html'
}
}
else
{
alert(t1) ;
}
Merci de votre aide quand meme
Lassé par la pub ? Créez un compte