Bienvenue sur PEBKAC.fr, le site qui recense les anecdotes où l’on se moque des utilisateurs ne maîtrisant pas l’outil informatique. PEBKAC est un acronyme signifiant « Problem Exists Between Keyboard And Chair ».var champTags = [,,,,,,,,,,];
champTags[0] = '1'; //v
champTags[1] = document.getElementById("mail").value;
champTags[2] = 'SomeData';
champTags[3] = '';//num com
champTags[4] = document.getElementById("telephone").value;
champTags[5] = ''; //migra
champTags[6] = ''; //rio
champTags[7] = $("input[name=civilite]:checked").next("span").text();
champTags[8] = document.getElementById("nom").value;
champTags[9] = document.getElementById("prenom").value;
var string = "something/" + champTags[0] + '/' + champTags[1] + '/' + champTags[2] + '/' + champTags[3] + '/' + champTags[4] + '/' + champTags[5] + '/' + champTags[6] + '/' + champTags[7] + '/' + champTags[8] + '/' + champTags[9] + ';'
array pour les remplir juste après, l'auteur de cette perle ne semble manifestement pas connaître le fort utile Array.prototype.join();. PEBKAC.
$("input[name=civilite]:checked").next("span").text();
var id = '1'; //v
var mail = document.getElementById("mail").value;
var data = 'SomeData';
var com = '';//num com
var phone = document.getElementById("telephone").value;
var migra = ''; //migra
var rio = ''; //rio
var isChecked = $("input[name=civilite]:checked").next("span").text();
var name = document.getElementById("nom").value;
var firstName = document.getElementById("prenom").value;
var string = "something/" + id + '/' + mail + '/' + data + '/' + com + '/' + phone + '/' + migra + '/' + rio + '/' + isChecked + '/' + name + '/' + firstname + ';'
var string = "something/" + '1' + '/' + document.getElementById("mail").value + '/' + 'SomeData' + '/' + '' + '/' + document.getElementById("telephone").value + '/' + '' + '/' + '' + '/' + $("input[name=civilite]:checked").next("span").text() + '/' + document.getElementById("nom").value + '/' + document.getElementById("prenom").value + ';'
var champTags = [,,,,,,,,,,];
champTags[0] = '1'; //v
champTags[1] = document.getElementById("mail").value;
champTags[2] = 'SomeData';
champTags[3] = '';//num com
champTags[4] = document.getElementById("telephone").value;
champTags[5] = ''; //migra
champTags[6] = ''; //rio
champTags[7] = $("input[name=civilite]:checked").next("span").text();
champTags[8] = document.getElementById("nom").value;
champTags[9] = document.getElementById("prenom").value;
var string = champTags.join('/')
.join('/') ?
var string = "something/" +
'1/' + //v
document.getElementById("mail").value + '/' +
'SomeData' + '/' +
'/' + //num com
document.getElementById("telephone").value + '/' +
'/' + //migra
'/' + //rio
$("input[name=civilite]:checked").next("span").text() + '/' +
document.getElementById("nom").value + '/' +
document.getElementById("prenom").value + ';';+ est extrêmement lent, et utiliser un tableau peut alors se justifier.... si on utilise join !span adjacent plutôt que dans son attribut value, ça tient aussi du PEBKAC.
var string = 'something/' + champTags.join('/')
champTags = [
'1', //v
document.getElementById("mail").value,
'SomeData',
'',//num com
document.getElementById("telephone").value
// [etc...]
]champTags = [];
champTags.push('1'); // to be continued....join() n'est pas le PEBKAC car même sans join() on peut tout de même faire un truc propre avec une boucle, au lieu de tout se taper à la main :var string = "something";
for (var i = 0; i<champTags.length;i++) {
string += '/' + champTags[i];
}something/mail@domain.fr/SomeData//0123456789///Mr/Truc/Muche... pour moi il ne peut s'agir que d'une sorte de sérialisation... Pourquoi ne pas passer par du JSON dans ce cas ?<input type="checkbox" name="cb_mister" value="Mister" >Mister
faire une boucle qui au final reproduit le fonctionnement d'une fonction native ce n'est pas vraiment malin. je suis on ne peut plus d'accord, j'illustrais simplement le fait que ne pas connaître une fonction (en plus de ne pas vérifier si elle existe, ce qui est une autre histoire sur laquelle j'ai volontairement fait l'impasse) qui pourrait nous être utile n'est pas une excuse pour produire un code dégueulasse.