[(TRES) DEBUTANT] ecrire un string modifie dans un input
Bonjour,
Je desire ecrire un objet string modifie par une fonction js (qui ajoute des 0 a partir de gauche) dans l'input dans lequel cet objet a ete saisi par l'utilisateur. Mais je n'y arrive pas. Quelqu'un pourrait-il m'indiquer une solution? Merci.
Voici le code test:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<script type="text/javascript">
function pleasePadMyString(myString, lengthString, character){
newMyString = new Array(lengthString - ('' + myString).length + 1).join(character) + myString;
return newMyString;
}
</script>
</head>
<body>
<input type="text" name="myString" value="345" ><img src="complete1.gif" style="cursor:hand;" title="Format" onclick="pleasePadMyString(345, 11, '0'); alert(pleasePadMyString(345, 11, '0'));" /><br>
</body>
</html> |
Cordialement.
P.S.: veuillez pardonner mon francais approximatif.