Bonjour, Je vais tenter d'expliquer du mieux que je peux mon probleme. Pour commencer je fais une feuille de temps. J'ai déja plusieurs input de présent qui sont la statiquement voici à quoi ils ressemblent
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
<!-----------------------------------LUNDI----------------------------------------------------->
<tr>
<td>
<b>
Lundi
</b>
</br>
<?php echo $date2 ?>
<div id="lundicon">
<p id="add_lundi" class="plus">
<a href="#"><span> + </span> </a>
</p>
</div>
</td>
<td>
</br>
<div id="numlundi">
<input onblur="autre();" onfocus="enter();" size="10" type="text" id="projlundi"
name="projlundi" onkeypress="return handleEnter2(event, this, 'task');"
/>
</div>
</td>
<td>
</br>
<div id="clientlun">
<input type="text" name="clientlundi" onblur="autre();" onfocus="enter();"
class="client" size="12" id="clientlundi" readonly />
</div>
</td>
<td>
</br>
<div id="prodesclun">
<input type="text" name="projdesclundi" onblur="autre();" onfocus="enter();"
size="30" class "desc" id="projdesclundi" readonly />
</div>
</td>
<td>
</br>
<div id="protachelun">
<textarea rows="1" cols="20" name="taskdesclundi" id="taskdesclundi" onblur="autre();"
onfocus="enter();" />
</textarea>
</div>
</td>
<td>
</br>
<div id="prolieudivlun">
<input type="text" onblur="autre();" onfocus="enter();" name="lieu1" size="10">
</div>
</td>
<td>
</br>
<div id="tachedivlun">
<!-- dꣵt section cobobox tache avec tool tip -->
<label title="Selectlundi">
<select title="Selectlundi" id="Selectlundi" onblur="autre();" onfocus="enter();"
name="Selectlundi">
<?php $stmt->
execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '
<option title="';
echo $row['tacName'];
echo '">
'; echo $row['tacId']; echo '
</option>
'."\n"; $task = array(); //echo '
<option value="'.$row['tacName'].'">
'.$row['tacId'].'
</option>
'."\n"; } ?>
</select>
</label>
</div>
<!-- Fin section cobobox tache avec tool tip -->
</td>
<!-- calculter le temps pour le lundi -->
<td>
</br>
<span id="calculTemps1">
<div id="calculTempsdivlun">
<input step="any" type="number" id="input2" class="temps" onblur="autre();"
onfocus="enter();" name="tempsl" max="24" min="0" value="0" />
</div>
</span>
</td>
<td>
<div id="tempsluntotal">
<input step="any" type="text" id="tempsluntotal" class="temps" onblur="autre();"
onfocus="enter();" name="tempsluntotal" size="5" value="0" />
<br/>
</div>
</tr> |
Donc mon numlundi quand j'écrit 07-0 il me suggesre des nombre du genre 07-0616 , 07-0138. Quand je click sur exemple 07-0138 et j'appuie sur enter il complete mon champs client et mon champs description avec les données liés.
Voici comment je complete mes données de facon static
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| //------------------COMPLETE CLIENT DESC LUNDI----------------------
function handleEnter2(e, obj, field) {
if (e.keyCode == 13 || e.which == 13) {
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
tempArrayInJS = JSON.parse(xmlhttp.responseText);
$("#clientlundi").val(tempArrayInJS[0]['cliName']);
$("#projdesclundi").val(tempArrayInJS[0]['proDescription']);
}
}
xmlhttp.open("GET", "completeclient.php?q=" + obj.value, true);
xmlhttp.send();
}
//Enter was pressed, handle it here
} |
J'ai créer un bouton add input ( il ajoute en dessou de numludi , clientlundi etc des inputs dynamique)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| //function append lundi
var counterlundi = 0;
var $newRow;
$(function () {
$('#add_lundi').click(function () {
console.log('test')
counterlundi += 1;
// $('#numlundi').append(
// $newRow = $('<input id="numlundi' + counterlundi + '" name="numlundi[]' + '" type="text" onblur="autre();" onfocus="enter();"/> ')
// )
$newRow = $('<input id="numlundi' + counterlundi + '" name="numlundi[]' + '" type="text" onblur="autre();" onfocus="enter();"/> ');
$('#numlundi').append($newRow)
$newRow.autocomplete(autocompOpt);
$('#clientlun').append(('<input id="clientlundi' + counterlundi + '" name="clientlundi[]' + '" type="text" onblur="autre();" onfocus="enter();" />')
)
$('#prodesclun').append(('<input id="prodesclun' + counterlundi + '" name="prodesclun[]' + '" type="text" onblur="autre();" onfocus="enter();" />'))
$('#protachelun').append(('<textarea id="protachelun' + counterlundi + '" name="protachelun[]' + '" type="text" rows="1" cols="20" onblur="autre();" onfocus="enter();"/>'))
$('#prolieudivlun').append(('<input id="prolieudivlun' + counterlundi + '" name="prolieudivlun[]' + '" type="text" onblur="autre();" onfocus="enter();" />'))
select = $('<select id="tachedivlun' + counterlundi + '" name="tachedivlun[]" type="text" onblur="autre();" onfocus="enter();"/>');
select.append($("#Selectlundi option").clone());
$("#tachedivlun").append(select);
$('#calculTempsdivlun').append(('<input id="calculTempsdivlun' + counterlundi + '" name="calculTempsdivlun[]' + '" type="number" size="10" min="0" max="24" value="0" class="dynamic" onblur="autre();" onfocus="enter();"/>'))
});
});
var autocompOpt = {
source: 'getautocomplete.php',
minLength: 1
} |
Mon probleme est apres qu'il me suggère dans mes champs dynamiques des chiffres je ne sais pas comment appeler la fonction pour qu'il me complete mes champs de facons dynamique quand enter est appuyer. Comme quand je fais de facon static. Comment faire? J'ai essayer d'entré
onkeypress="return handleEnter(event, this, 'task');"/>
dans mon append lundi avec une facon dynamique mais sans résultat. j'ai essayer avec des antislash aussi pour les guillemets. donc si vous savez comment faire je suis preneur!
Je travaille en php et javascript principalement.
EDIT
J'ai essayer ca $('#numlundi').keypress (function (e) { return handledyn(event, this, 'task');}) en dessou de mon append
avec cette function la
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
//------------------COMPLETE CLIENT DESC dynamique----------------------
function handledyn(e, obj, field){
var i = 0 ;
i = i + 1 ;
if (e.keyCode == 13 || e.which == 13){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
tempArrayInJS = JSON.parse(xmlhttp.responseText);
$("#clientlundi"+i).val( tempArrayInJS[0]['cliName']);
$("#projdesclundi").val( tempArrayInJS[0]['proDescription']);
}
}
xmlhttp.open("GET","completeclient.php?q="+obj.value,true);
xmlhttp.send();
}
//Enter was pressed, handle it here
} |
mais ca ne marche pas plus. mais peut etre cela donnerait une piste a quelqu'un qui peut m'aider.
Partager