Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create bookmarklet to fill form [closed]

I want to create a bookmarklet that fills in 1st, 2nd, 5th and 6th text box with text so I can use the tool on the site more easily, because I use it frequently & it doesn't remember my input. These are the ones with this text in front "Vertrek gemeente :" , "Straat :", "Aankomst gemeente :" and "Straat :".

Let me give some test values (in order)

"gent"
"PATIJNTJESTRAAT"
"OOSTAKKER"
"HERMAN TEIRLINCKSTRAAT"

about the site: it is a dutch public transport site were you can input your street and the destination street and then the web application will calculate which busses you should take and when you should take them.

about me: I am a rookie at javascript. I know you can use getElemenbyId but this site has a lot of scripts & such wich makes it hard to get the id. I do know there is a (firefox) addon+plugin which makes you inspect elements (to get the id). It's called firebug. I hope this is of any help. I'm not 100% sure bookmarklets is the way to fix my problem, if you got other suggestions feel free to reply (I heard cookies might be a solution? Or maybe a firefox addon?)

Thanks in advance if you can help to get the (javascript bookmarklet) code for this or a possible solution, Thank you even more if you provide me with working code. Thank a million if you are so kind to provide me with the code & explain how it truly works.

like image 728
user1430392 Avatar asked Jul 02 '12 11:07

user1430392


People also ask

How do you use bookmarklets?

Just click the bookmarklet and your browser will run it on the current page. If you don't have a bookmarks toolbar — such as on Safari on an iPad or another mobile browser — just open your browser's bookmarks pane and tap or click the bookmark.

How do you use bookmarklets on Android?

Using the BookmarkletStart typing “Android bookmarklet” into the address/URL above resource. Choose the suggestion with “javascript:void” below it to trigger the bookmarklet. You will be prompted to log in via CalNet or PIN / Cal 1 card. Once authenticated as UCB, you should get access.


1 Answers

Try this :

javascript: { document.getElementById('form1:vertrekGemeenteInput').value = 'Zedelgem';document.getElementById('form1:vertrekStraatInput').value = 'Berkenhagestraat';document.getElementById('form1:vertrekNrInput').value = '44';document.getElementById('form1:aankomstGemeenteInput').value = 'Oostakker';document.getElementById('form1:aankomstStraatInput').value = 'Herman Teirlinkcstraat';document.getElementById('form1:aankomstNrInput').value = '1'; void(0) }

I tested this on Chrome, it works there.

As for getting the element, Open Chrome, then open the inspector ( on windows that is Control Shift J ), then hit the magnifying glass in the bottom left corner, then you hoover over the web page and you see elements turn blue, if you click on any element you will see in the Elements tab the relevant tag and you will see the id, that's how I found these id's. Je bent welkom ;)

like image 88
tomdemuyt Avatar answered Nov 14 '22 05:11

tomdemuyt