Salutation je ne savais pas trop ou mettre se post mais bon je ne pense pas mettre trompé enfin bref
j'ai un petit soucis voila le code :
Code :
- <HTML>
- <HEAD>
- <TITLE>Insert</TITLE>
- <SCRIPT LANGUAGE="JavaScript">
- function storeCaret (textEl)
- {
- if (textEl.createTextRange)
- textEl.caretPos = document.selection.createRange().duplicate();
- }
- function insertAtCaret (textEl, text)
- {
- if (textEl.createTextRange && textEl.caretPos)
- {
- var caretPos = textEl.caretPos;
- caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
- }
- else
- textEl.value = text;
- }
- </SCRIPT>
- </HEAD>
- <BODY>
- <FORM METHOD="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <?php
- include_once('../fonctions.php');
- connect();
- $sql= "SELECT mot FROM motcle";
- $res=mysql_query($sql);
- echo'<select name="mot">';
- echo"<option></option>";
- while ($row=mysql_fetch_array($res)){
- $mot=$row['mot'];
- echo "<option value=\"$mot\">$mot</option>";
- echo "</option>"; }
- if(!empty($_POST['mot']))
- {
- $mot=$_POST['mot'];
- ?>
- <textarea rows="5" name="zonetexte" cols="20"ONSELECT="storeCaret(this);"ONCLICK="storeCaret(this);"ONKEYUP="storeCaret(this);"></textarea>
- <INPUT TYPE="button" STYLE="font-family:courier;" VALUE="Ajouter" ONCLICK="insertAtCaret(this.form.zonetexte,".$mot." );">
- </FORM>
- <?php
- }
- ?>
- </BODY>
- </HTML>
|
en faite il s'agit d'un script qui permet d'ajouter un mot à la position du curseur quand on met un mot simple exemple: avec toto
Code :
- <INPUT TYPE="button" STYLE="font-family:courier;" VALUE="Ajouter" ONCLICK="insertAtCaret(this.form.zonetexte,'toto');">
|
tout va bien
mais moi je voudrais prendre un mot venant de ma bdd
Code :
- <INPUT TYPE="button" STYLE="font-family:courier;" VALUE="Ajouter" ONCLICK="insertAtCaret(this.form.zonetexte,".$mot." );">
|
alors j'ai fait ceci mais sa ne marche pas.
Pouvez-vous m'aider s'il vous plait
Je vous remercie d'avance