Forum Moderators: open

Message Too Old, No Replies

Sending text to other websites via links

         

boywunder

12:36 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



Hello all, this is my first post here but I have been using the site now for a while.

My question is this:
I am making a website for a hotel which is using an external booking system on a different site. At the moment they have a simple link to their booking page on this site, from where you can enter dates, numbers etc.

Does anyone know if it is possible using javascript (or anything for that matter) to take a date typed in on the first site, and have it automatically sent to the booking site when you click the hyperlink, so that their form is filled in when it loads?

thanks

Kings on steeds

4:11 pm on Mar 22, 2009 (gmt 0)

10+ Year Member



you would need control of the code on the second site, either control of the js or the processing lang of the site (probs php) then you could either set a variable that fills in your box, or write a script such as


function getVar(name){
var url = window.location.toString();
var arr = url.split('?');
var no = arr.length;
if(no > 1){
var nArr = arr.slice(1);
for (var i = 0;i< nArr.length;i++)
{
var h = {name: "", value: ""}
var temp = nArr[i].split('=');
h.name = temp[0];
h.value = temp[1];
if(h.name == name){
return h.value;
}
}
}
}
document.form['name'].datefield.value = getVar("date");

note: script untested, just an example.

edit: script needs to resplit nArr's values at "&" to gather other vars before testing 'name'

then you would just need to pass the date in the url like, www.example.net?date=12/12/12

hope that helps.

[edited by: Kings_on_steeds at 4:13 pm (utc) on Mar. 22, 2009]

[edited by: eelixduppy at 5:33 pm (utc) on Mar. 22, 2009]
[edit reason] formatting [/edit]

boywunder

9:57 pm on Mar 22, 2009 (gmt 0)

10+ Year Member



Ahh right thanks. So if I have no control over the second site, there is no way to automatically fill in the forms on it then?

g1smd

10:17 pm on Mar 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Indeed the other site might have things in place to stop people automatically filling in forms.

However, they might have an API for their booking engine that you can utilise. Ask them.