Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dumb question: document.referrer into a form

Status
Not open for further replies.

platypus55

Programmer
Aug 15, 1999
32
US
I want to put document.referrer into a form before sending it off. <br>
<br>
form is name theform (let's say) <br>
has a hidden named theurl //this is where I want document.referrer to go<br>
<br>
After all the html for the form I say<br>
<br>
&lt;script language=&quot;javascript&quot;&gt;<br>
document.theform.theurl.value = document.referrer;<br>
&lt;/script&gt;<br>
<br>
But what gets sent is the original value not document.referrer! I've tried other things too, like an onsubmit routine but I think passing it as a parameter only works on a copy or something because nothing seems to change it!!! This should be trivial. What am I doing wrong!!
 
How 'bout just leaving your form open ended (i.e. no &lt;/form&gt; tag) and deploying a <b>document.writeln('&lt;input type=hidden name=refURL value='+document.referrer+'&gt;')</b> in your &lt;body&gt; tag as an &quot;onLoad()&quot; event.<br>
<br>
Please let me know if this works. <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= > </a><br>*nix installation & program collector/reseller. Contact me if you think you've got one that I don't :)
 
Thanks for the suggestion! Before I go off and try this, I need to know if a CGI cares what order the form elements are in as long as they are named. In this particular case the <br>
weburl field is only the 2nd one in the form and I presume I would have to document.write the rest of the form (it is quite extensive and formatted, ick) or can I just leave the form with no &lt;/form&gt; as you suggest, <br>
document.write the field with the referrer in it at the END, and the rest of the page, then, including the &lt;/form&gt; <br>
<br>
I guess I'll just try it this way first.
 
As far as my experience takes me...I have not yet met up with a CGI program that was so poorly written as to not accept a form input if it's in the wrong order; but let me know if you find one & we'll try to find a way to efficiently work around it :) <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= > </a><br>*nix installation & program collector/reseller. Contact me if you think you've got one that I don't :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top