Probleme affectation valeur input svp!
gamermelee
Messages postés
110
Statut
Membre
-
Max -
Max -
salut à tous.En tant que debutant en la matiere , j'ai besoin d'un peu d'aide.
Voila en faite, j'aimerais que dans une fonction javascript la valeur d'un input prenne pour valeur le nom d'un bouton.
voici tout mon code de page pour voir une vue d'ensemble :
<?
require('traitement.php')
?>
<html>
<head>
<TITLE>Gestion. SARL BLANCHARD PINEAU
</title>
<link rel="stylesheet" type="text/css" href="style.css">
<STYLE>
.tabnormal{background-color:'#fdf5e6'}
.tabover{background-color:'#7BC7F7'}
</STYLE>
</head>
<body >
<script type="text/javascript">function Go(){return}</script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="menu9_com.js"></script>
<noscript>
Your browser does not support script
</noscript>
<table height=100% width= 100% border="1" >
<TR>
<td >
<TABLE height=89% width= 100% border="1" align="center" >
<TR align="center">
<TD align="center">
<?php
$indic_result_connexion = connexion_srv_et_bd();
if ( strcmp($indic_result_connexion,'ok')==0)
{
$consult=consult_pers_nom();
consult_pers_nom();
echo '<div align="right" style="width:95%;overflow:auto;">';
echo '<table border="3" BGCOLOR="#D9D9F3" bordercolor="#0000ff" height = "20px" style="width:96%;overflow:hidden">';
echo '<TR>';
echo '<td width=16% >Nom</td>';
echo '<td width=13%>Prenom</td>';
echo '<td width=14%>Telephone</td>';
echo '<td width=14%>Fonction</td>';
echo '<td width=14%>Type</td>';
echo '<td width=29%><A HREF="v_accueil_contact_societe.php"><img border=0 align=right SRC="fleche.bmp"</A>Societe<td>';
echo '</TR>';
echo '</table>';
echo '<div style="width:100%;height:250px;overflow-Y:auto;">';
}
else
{
if ( strcmp($indic_result_connexion,'kobd')==0)
{
echo "la connexion a la base de données n a pas eu lieu";
}
else
{
echo "La connexion au serveur n a pas eu lieu";
};
}
while ($ligne=mysql_fetch_array($consult))
{
echo '<table border="1" valign="middle" BGCOLOR="#fdf5e6" bordercolor="#0000ff" height = "20px" style="width:100%;overflow:hidden">';
echo '<tr width=4% class="tabnormal" onclick="this.className=\'tabover\'" ondblclick="this.className=\'tabnormal\'" onmouseover=\'document.forms["changer"].truc.value = "affichage" \'>';
echo"<td width=3%>" ;
?><form action="v_fiche_contact.php" method="get"><input type="text" name="code_pers" style="width:1px;" value="<? echo $ligne['num_personne'] ?>" ondblclick="document.location.href='v_fiche_contact.php'" onclick=><Input type="submit" value="<? echo $ligne['num_personne'] ?>" style="width:30px;" name="azerty">
<?php
echo"</td>";
?>
</form>
<?php
echo "<td width=15% >";
echo $ligne['nom_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['prenom_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['tel_professionel_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['lib_fonction'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['lib_type_pers'];
echo"</td>";
echo"<td width=29%>" ;
echo $ligne['raison_social'];
echo"</td>";
echo "</tr>";
echo "</Table>";
};
?>
</form>
<form name="changer"><input type="text" name="truc" value="100"></form>
</TD>
</TR>
</table>
<form action="index.php"><input type="submit" value="Fermer" ></form>
</TD>
</TR>
</table>
</body>
</Html>
le premier soulignement represente la fonction javascript où l'on doit mettre le code , le deuxieme represente le boutton et/ou le input (meme valeur) et le dernier soulignement represente le input où doit s'afficher la valeur du bouton.
voila merci d'essayer de m'aider et de me proposer des ou une solutions...
Voila en faite, j'aimerais que dans une fonction javascript la valeur d'un input prenne pour valeur le nom d'un bouton.
voici tout mon code de page pour voir une vue d'ensemble :
<?
require('traitement.php')
?>
<html>
<head>
<TITLE>Gestion. SARL BLANCHARD PINEAU
</title>
<link rel="stylesheet" type="text/css" href="style.css">
<STYLE>
.tabnormal{background-color:'#fdf5e6'}
.tabover{background-color:'#7BC7F7'}
</STYLE>
</head>
<body >
<script type="text/javascript">function Go(){return}</script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="menu9_com.js"></script>
<noscript>
Your browser does not support script
</noscript>
<table height=100% width= 100% border="1" >
<TR>
<td >
<TABLE height=89% width= 100% border="1" align="center" >
<TR align="center">
<TD align="center">
<?php
$indic_result_connexion = connexion_srv_et_bd();
if ( strcmp($indic_result_connexion,'ok')==0)
{
$consult=consult_pers_nom();
consult_pers_nom();
echo '<div align="right" style="width:95%;overflow:auto;">';
echo '<table border="3" BGCOLOR="#D9D9F3" bordercolor="#0000ff" height = "20px" style="width:96%;overflow:hidden">';
echo '<TR>';
echo '<td width=16% >Nom</td>';
echo '<td width=13%>Prenom</td>';
echo '<td width=14%>Telephone</td>';
echo '<td width=14%>Fonction</td>';
echo '<td width=14%>Type</td>';
echo '<td width=29%><A HREF="v_accueil_contact_societe.php"><img border=0 align=right SRC="fleche.bmp"</A>Societe<td>';
echo '</TR>';
echo '</table>';
echo '<div style="width:100%;height:250px;overflow-Y:auto;">';
}
else
{
if ( strcmp($indic_result_connexion,'kobd')==0)
{
echo "la connexion a la base de données n a pas eu lieu";
}
else
{
echo "La connexion au serveur n a pas eu lieu";
};
}
while ($ligne=mysql_fetch_array($consult))
{
echo '<table border="1" valign="middle" BGCOLOR="#fdf5e6" bordercolor="#0000ff" height = "20px" style="width:100%;overflow:hidden">';
echo '<tr width=4% class="tabnormal" onclick="this.className=\'tabover\'" ondblclick="this.className=\'tabnormal\'" onmouseover=\'document.forms["changer"].truc.value = "affichage" \'>';
echo"<td width=3%>" ;
?><form action="v_fiche_contact.php" method="get"><input type="text" name="code_pers" style="width:1px;" value="<? echo $ligne['num_personne'] ?>" ondblclick="document.location.href='v_fiche_contact.php'" onclick=><Input type="submit" value="<? echo $ligne['num_personne'] ?>" style="width:30px;" name="azerty">
<?php
echo"</td>";
?>
</form>
<?php
echo "<td width=15% >";
echo $ligne['nom_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['prenom_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['tel_professionel_pers'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['lib_fonction'];
echo"</td>";
echo"<td width=13%>" ;
echo $ligne['lib_type_pers'];
echo"</td>";
echo"<td width=29%>" ;
echo $ligne['raison_social'];
echo"</td>";
echo "</tr>";
echo "</Table>";
};
?>
</form>
<form name="changer"><input type="text" name="truc" value="100"></form>
</TD>
</TR>
</table>
<form action="index.php"><input type="submit" value="Fermer" ></form>
</TD>
</TR>
</table>
</body>
</Html>
le premier soulignement represente la fonction javascript où l'on doit mettre le code , le deuxieme represente le boutton et/ou le input (meme valeur) et le dernier soulignement represente le input où doit s'afficher la valeur du bouton.
voila merci d'essayer de m'aider et de me proposer des ou une solutions...
A voir également:
- Probleme affectation valeur input svp!
- Input not supported - Forum Ecran
- Input signal not found ✓ - Forum Matériel & Système
- Logiciel gratuit calcul valeur nutritionnelle - Télécharger - Santé & Bien-être
- Valeur relative et absolue ✓ - Forum Webmastering
- Input ou output ✓ - Forum Audio
1 réponse
Pour commencer, tu dois ajouter l'attribut "id" à ton bouton et à ton champ texte ( ex.: <input type="submit" id="bouton-1"> ). Ceci te permettra d'y faire référence par javascript.
Par javascript ensuite tu appliques entre la ligne suivante pour attribuer au champ texte la valeur de ton bouton :
document.getElementById("id-de-ton-champ-texte").value = document.getElementById("id-de-ton-bouton").value;
Je crois bien qu'avec ça tu devrais être OK pour ce que tu as besoin de faire!
Par javascript ensuite tu appliques entre la ligne suivante pour attribuer au champ texte la valeur de ton bouton :
document.getElementById("id-de-ton-champ-texte").value = document.getElementById("id-de-ton-bouton").value;
Je crois bien qu'avec ça tu devrais être OK pour ce que tu as besoin de faire!