PDA

View Full Version : Display URL of previous page in html form



Optimist
06 Feb 2011, 08:46 AM
Hello
I am a pesky beginner. I create websites using Lauyan WYSIWYG software but sometimes I need to use more complex functions. For the moment I've managed by copying bits of scripts and adaping them but this time I've run into a brick wall. And I am sure it should be easy and all my tries have probably failed for syntax error or a missing var or something.
So I really would appreciate somebody to take me slowly through this one.

I am making a site for a travel agency. On each page (over 150) there should be a contact form which should include the tour name or code the person is interested in.

Rather than creating (and maintaining) 150 contact forms what I would like to do ideally is : keep the 150 pages but add a button to a common "Booking & Enquiries" form. So far that's OK. But I would like the form to have a hidden field with a variable value. This value could just be the URL of the sending page. I can display the value of the current URL with window.location and put it in a var.

Now I just need how to know how to put it in the wg-formfield


<td align="left" valign="top"><input class="wg-formfield" type="text" name="nameoftour" value="" maxlength="100" style="width:300px;">in the value part.

I've tried creating a javascript displaying the value of the current URL :

<script type="text/javascript">
var nameoftour = window.location.href;
document . write (nameoftour);
</script>
but I want :
a) to pass it on to the next page
b) to display as value in the form either as hidden or as read-only

Can anybody help please ?
Thank you very much in advance for your help.