Bonjour,
C'est mon premier post sur le forum javascript mais je ne sais pas si c'est le bon forum pour l'AJAX (peut être un forum dedié à celui-ci ??)...
Mon problème se situe au niveau de la récupération des donnée d'un formulaire:
J'obtiens bien 'hide1' mais je n'arive pas à avoir 'hide2'... Est-ce normal?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <form id="form1"> <input type="hidden" id="hide1" value="42" /> <table> <tr> <td> <input type="hidden" id="hide2" value="4242" /> </td> <td> <input type="checkbox" onClick="updateData('url')"> </td> </tr> </table> </form> <div id="res"></div> <script type="text/javascript"> function updateData(url) { var req = new DataRequestor(); req.addArgsFromForm('forms1'); req.setObjToReplace('res'); req.getURL(url); } </script>
voila le code pour recuperer les arguments mais honnetement je ne comprend pas trop ...
Merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 /** * Adds all the variables from an HTML form to the GET or * POST strings, based on the `method` attribute` of the * form * @param formID the ID of the form to be added */ this.addArgsFromForm = function(formID) { var theForm = document.getElementById(formID); // Get form method, default to GET var submitMethod = (theForm.getAttribute('method').toLowerCase() == 'post')?_POST:_GET; // Get all form elements and use `addArg` to add them to the GET/POST string for (var i=0; i < theForm.childNodes.length; i++) { theNode = theForm.childNodes[i]; switch(theNode.nodeName.toLowerCase()) { case "input": case "select": case "textarea": this.addArg(submitMethod, theNode.id, theNode.value); break; } } }
Partager