HTML Question from an HTML Ignoramus

Imagine a bunch of web pages (HTML documents), each of which contains a link to bring the browsing person to the same web page (again, a static HTML document) to fill out a form.

The form web page is provided in its entirety by a 3rd party–although I can create fields for users to fill out (and might be able to create fields that users don’t see, not sure of that yet), I don’t have a free hand to set up anything complicated there.

The “bunch of web pages” are in the free FTP space that comes along with internet access from my ISP, and again I don’t have a free hand as far as setting up CGI that requires them to be running anything in particular on the server in order to process it. (In fact, they are willfully unhelpful w/ regards to this feature in its entirety and will not answer ANY QUESTIONS WHATSOEVER because “we do not support it”). Aside from which, I know no more about writing CGI than my dog does.

So, the question: if there an easy way of passing a parameter along from each and any of the “bunch of web pages” to the form web page so as to fill in which originating page the browsing person came from? Can I do this with straight HTML? I don’t need to keep any secrets here from the end users, so it is OK if they see the field already filled out, or see code in the URL.

My level of expertise: With luck, I can make text be bold or italic using HTML tags. (I guess it is fair to say I know what a tag is). For anything else, I need a working example to copy and modify.

to get the parameters from those pages to the form you just append the url specified in the link like this;



<a href="http://www.formsdomain.com/formpage.html?parametername=prametervalue">go to form</a>


But then to get the value into the form so that it can be posted by the form, I think you will need some server side scripting. Actually, with asp, I assume with other technologies as well, the form page can detect the referer page url even without passing this information on explicitly.

Either way you are going to need to do some server side processing on the server storing the form. If that server supports asp, I would be able to help you on that.

If the form itself contains (let’s say) a Field_X, of the sort that would normally be typed into by the user, can I do something like make this be the link URL from the referring page–

http://www.formsdomain.com/formpage.html?Field_X=referringpagename

–and expect an ordinary HTML page with form stuff on it (i.e., the form page) show up with that field pre-filled-in?

Or are you saying that the ability to “catch” that information and plug it into the fields depends on server-side CGI?

Something like this might work…


<SCRIPT LANGUAGE="JavaScript">

document.write('<input type="hidden" value="' + document.referrer + '">');

</SCRIPT>

in some browsers, some of the time.

Bloody hell. The hypothetical URL looks like this (minus the http: prefix since I don’t want vBcode to parse it and shorten it):

//ww.formsdomain.com/formpage.htm l?Field_X=referringpagetitle

Lance, I know the words “Java Script” and if I have an exact copy of a page with working Java Script on it that does essentially what I want it to do, I can often purloin it, swapping out some of its parameters for those that are applicable to my purposes.

But I can’t write the stuff.

Is your example a complete example, or were you assuming I’d know what else to embed in it (and/or the receiving page) in order for it to work?

AHunter3 is right about the name/value pairing to pass the value in the URL. Though doing this in an ASP page would be a lot easier, it isn’t entirely necessasary…

For each page that links to the form, you could add at the end of the url the name of the page (or a nickname that you would understand) preceded by a “?” which would get added to a hidden field.



<html>
<head>
<title>Getting the Referring Page</title>
<script language="javascript">
	function getRef() {
		var loc, reqURL = "";
		var len = 0;
		var ref = "";
		
		reqURL = window.location.href;
		loc = reqURL.indexOf("?") + 1;
		len = reqURL.length;

		ref = reqURL.substring(loc, len);
		alert(ref);	
		document.test.refer.value = ref;
	}
</script>
</head>
<body>
To test, click on one of the links below, then hit the submit button.

<br><br><br>
<a href="get_ref_page.html?main">Main</a><br><br>
<a href="get_ref_page.html?contact">Contact</a><br><br>
<a href="get_ref_page.html?left">Left</a><br><br>
<a href="get_ref_page.html?right">Right</a><br><br>

<form name="test" onSubmit="getRef();">
	<input type="hidden" name="refer">
	<input type="submit" value="Submit">
</form>
</body>
</html>


Upon a closer look, my example is not quite complete. There should be a ‘name’ attribute in the hidden tag. Let’s try that again.



<SCRIPT LANGUAGE="JavaScript">

document.write('<input type="hidden" name="reefer" value="');
document.write(document.referrer + '">');

</SCRIPT>


I broke it into two line to keep from side scrolling, but that isn’t necessary.

This should go somewhere in the body of your form page. It will pass the url of where you came to the form from to whatever program you’re using to process the form using the variable ‘reefer’. You can change that of course.

There is no means of adding JavaScript to the form page. Only to the referring pages.

For the form page, I can only create/name/delete/etc various fields, and arrange to have the results forwarded to my email address. Not much else.

If the referring pages include their own name after a question mark at the end of the URL for the form page, will the form page, USING NOTHING OTHER THAN PLAIN VANILLA HTML, accept that as input-in-advance?

As is, or do I need to DO something to it first? (Keep in mind that I can’t do MUCH).

Well, I did the obvious thing: I manually typed the URL that would normally take me to the form page and added “?replyto=testing” to the end of it after the “.html” to see if it would auto-fill the form field named “replyto” with the string “testing”.

No go. :frowning:

OK, maybe, POSSIBLY, I have more control over the form than I thought I did.

Here is the portion of the editable code pertaining to the replyto field:

{{replyto}}
<tr>
<td valign=top align=right width=30%>Replying to…(Subject):</td>
<td>[[replyto]]</td>
</tr>
{{/replyto}}
What would I do to that to cause it to “inherit” the string passed from the referring page?

Oh, Lance, I’m not ignoring you, you’re just miles and miles over my head. I don’t know where you mean for me to put which code snippets where, and whether or not I need to edit some portion of it to make it work on my pages. Or which page(s) to put the code snippets on.

Baby talk, please.

OK, how about this? Is there some simple code I can put on the referring page to cause it to copy a string to the clipboard? Then I could simply have the user paste into the replyto field.

I can’t really see any way to do this without having javascript on both pages. Html documents are by their very static, so can’t toss variables around without having some sore of scripting support.

Are you sure that you don’t have any server side scripting available on your ISP account? I mean, it’s not likely, but you never know.

Try this… make a file named phpinfo.php with the following code:



<?
phpinfo();
?>


Upload it to your webspace and browse to it. If you get a bunch of interesting info, then you’ve got PHP installed, and I can write you your very own mail form in about five minutes.

I just had another idea…

Take a look at the source code for your remotely hosted submission form. You might be able to call the submission script remotely from a form on your server, and pass the values to the form submission page via javascript.

Upload it to the webspace where the various source web pages are located? That’s the only place I can upload anything. I can’t upload any files to the location (which is a different location) where the form page is located.

Yeah.

Yeah.

If it works, you should get something like this.

Doesn’t work.

http://members.bellatlantic.net/~adhdah/phpinfo.php

I honestly can’t think of a way to do it unless you can add a script to the form page or do something to the script that processes the form. You don’t seem to be able to do either so you might be stuck with the unreliable option of asking the user where they came from.

I’m also pretty sure that you can’t use a script to add something to the clipboard but I’d sure be interested if there was.

Got it solved, thanks to help from some geeks on another site who helped me do it in JavaScript. I misled you here–turns out I had more editing capability than I realized as far as the destination form was concerned, and was therefore able to embed JavaScript there. (I didn’t know I could do that–they make it look like you can’t)

Thanks for volunteering and trying to help.