Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. Hi guys,
  2. I just very quickly prepared something what could help you with buying group tickets now. It is javascript code which will automatically fill form about passengers. It accepts information about passengers in format "num;from;initials;surname;dateOfBirth;email;". Ex.:
  3. 1;Amsterdam;D;Trump;14.6.1946;e1@mail.com;
  4. 2;Utrecht;H;Clinton;26.10.1947;e2@mail.com;
  5. 3;Eindhoven;B;Obama;4.8.1961;e3@mail.com;
  6. 4;Maastricht;J;Chan;7.4.1954;e4@mail.com;
  7. 5;Den Haag Centraal;F;Hollande;12.8.1954;e5@mail.com;
  8. 6;Dordrecht;A;Merkel;17.7.1954;e6@mail.com;
  9. 7;Rotterdam;T;May;1.10.1956;e7@mail.com;
  10. 8;Zwolle;P;Gentiloni;22.11.1954;e8@mail.com;
  11. 9;Emmen;V;Orban;31.5.1963;e9@mail.com;
  12. 10;Almere;V;Putin;7.10.1952;e10@mail.com;
  13. Steps:
  14. 1.) Add new bookmark to your browser and instead URL address ("Location" in Firefox) put this JS code:
  15. javascript:(function() {
  16. var persons = prompt("Please enter your passengers' information:", "").split(";");
  17. var count = parseInt(persons.length / 6);
  18. for (idx = 1; idx <= count; idx++) {
  19. var from = persons[1 + (idx-1) * 6];
  20. var initials = persons[2 + (idx-1) * 6];
  21. var surname = persons[3 + (idx-1) * 6];
  22. var date = persons[4 + (idx-1) * 6].split(".");
  23. var day = parseInt(date[0]);
  24. var month = parseInt(date[1]);
  25. var year = parseInt(date[2]);
  26. var email = persons[5 + (idx-1) * 6];
  27. document.getElementsByName("Delivery_" + idx)[0].click();
  28. document.getElementsByName("Vertrekstation_" + idx)[0].value = from;
  29. document.getElementsByName("PO_Initials_" + idx)[0].value = initials;
  30. document.getElementsByName("PO_LastName_" + idx)[0].value = surname;
  31. document.getElementsByName("PO_BirthDate_" + idx)[0].getElementsByTagName("select")[0].value = day;
  32. document.getElementsByName("PO_BirthDate_" + idx)[0].getElementsByTagName("select")[1].value = month;
  33. document.getElementsByName("PO_BirthDate_" + idx)[0].getElementsByTagName("select")[2].value = year;
  34. document.getElementsByName("PO_BirthDate_" + idx)[1].value = day + "-" + month + "-" + year;
  35. document.getElementsByName("PO_Email_" + idx)[0].value = email;
  36. }
  37. })();
  38. 2.) Go to the website for buying group tickets: https://www.ns.nl/producten/en/s/ns-groepsretour and after filling a number of passengers, date and destination click on added bookmark (bookmark with JS code added in step 1.)).
  39. 3.) Browser asks you for passengers information in the format described above - copy and paste the information and submit.
  40. 4.) Can go to next steps - everything should be filled correctly.
  41. I do not have Dutch account so I have not tried to buy tickets with it, but successfully passed the first step with correct data filled so it could work correctly (at least until ns.nl personal do not change the source code of their website). I tested it with Chrome and Firefox. If there is someone who is better in JS - feel free to change the code and make it more "idiomatic".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement