By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

Determine which page form submitted from

P: 17
Also, theres something else i need help in, I have a form that people can put info in and sends me an email with the comments their email and their name, But i want to make it so that somehow when they click on the button on each page it gets some sort of info from each page so that i know from what page they clicked it from.
Aug 5 '08 #1
Share this Question
Share on Google+
18 Replies


acoder
Expert Mod 15k+
P: 16,027
I've split this from your other thread because it's a different question not related to that thread.

The property you're looking for is location.href. This will give you the URL of the current page.
Aug 5 '08 #2

P: 17
I've split this from your other thread because it's a different question not related to that thread.

The property you're looking for is location.href. This will give you the URL of the current page.
hmmm how will i translate this into my form when it sends me the email? any ideas?
Aug 5 '08 #3

RamananKalirajan
100+
P: 607
Hi Dude, just have an hiddden inpu element in that thing you just store the URl of the user, using document.URL. so that when they send the code to u. you will get the URL also through the hidden field. Any doubts post back it

Regards
Ramanan Kalirajan
Aug 6 '08 #4

P: 17
Hi Dude, just have an hiddden inpu element in that thing you just store the URl of the user, using document.URL. so that when they send the code to u. you will get the URL also through the hidden field. Any doubts post back it

Regards
Ramanan Kalirajan
yea thats how im using it right now, but thats with the form actually IN the page, but how would this work if it was a button or link or whatever linking it to another page/popup window that opens up the form?
Aug 6 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Then from the popup window, you can use window.opener.location.href to refer to parent window's URL.

By the way, if you're using server-side code, it'd be better to use that rather than depend on JavaScript code which could be altered.
Aug 6 '08 #6

RamananKalirajan
100+
P: 607
Hi dude use the idea Mr. Acoder has suggested. Thanks sir it will be helpful for me also.

Regards
Ramanan Kalirajan
Aug 6 '08 #7

P: 17
Then from the popup window, you can use window.opener.location.href to refer to parent window's URL.

By the way, if you're using server-side code, it'd be better to use that rather than depend on JavaScript code which could be altered.
Not sure by what you mean use server-side code, can you give me an example or something? And I will use whatever you think is best.

And where or how do i use window.opener.location.href, want to be able to use it so that for everypage, after they use my form and submit it, somewhere in the email it shows the "window.opener.location.href".
Aug 7 '08 #8

acoder
Expert Mod 15k+
P: 16,027
Server-side code means code on the server. JavaScript/HTML/CSS are client-side. PHP, ASP, JSP, Perl, Coldfusion, etc. are examples of server-side languages. Server-side code generates client-side code for the client. The first question is are you using one? If not, you'll have no choice but to use JavaScript.

To use window.opener.location.href, set a hidden input variable to this value, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="url" id="url">
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("url").value = window.opener.location.href;
You would put this JavaScript code in a function to be called onload. That's one way. There's other possibilities too.
Aug 7 '08 #9

P: 17
Server-side code means code on the server. JavaScript/HTML/CSS are client-side. PHP, ASP, JSP, Perl, Coldfusion, etc. are examples of server-side languages. Server-side code generates client-side code for the client. The first question is are you using one? If not, you'll have no choice but to use JavaScript.

To use window.opener.location.href, set a hidden input variable to this value, e.g.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="url" id="url">
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("url").value = window.opener.location.href;
You would put this JavaScript code in a function to be called onload. That's one way. There's other possibilities too.
I have PHP and ASP and dont have Perl, the others I am not sure, I have Godaddy Windows Hosting, I am thinking of switching over to Godaddy Linux Hosting, I'll take your opinion on that if you want to give it.

And also I would need help with writing the function.
Aug 7 '08 #10

acoder
Expert Mod 15k+
P: 16,027
You only need one language ;) That was only a list of possible languages.

Choose one whichever you feel most comfortable with. Then ask in the relevant forum.
Aug 7 '08 #11

P: 17
You only need one language ;) That was only a list of possible languages.

Choose one whichever you feel most comfortable with. Then ask in the relevant forum.

Does this work if its not a pop-up? If not can you help me with another method, doesnt have to be URL or anything, just something i can do to let me know which product they are asking about.
Aug 8 '08 #12

acoder
Expert Mod 15k+
P: 16,027
This should be done with your server-side language of choice. Which one are you using? The pages will be generated by the language and will have, for example, an id to refer to the product.

If you want to do this with JavaScript, you can use something like (on the same page) :
Expand|Select|Wrap|Line Numbers
  1. <form name="formName" id="formID" ...>
  2. <input type="hidden" name="url" value="">
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("formID").url.value = location.href;
As I said, though, this should be done with a server-side language.
Aug 8 '08 #13

P: 17
This should be done with your server-side language of choice. Which one are you using? The pages will be generated by the language and will have, for example, an id to refer to the product.

If you want to do this with JavaScript, you can use something like (on the same page) :
Expand|Select|Wrap|Line Numbers
  1. <form name="formName" id="formID" ...>
  2. <input type="hidden" name="url" value="">
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("formID").url.value = location.href;
As I said, though, this should be done with a server-side language.
yea can we use PHP as the server side language? and what do you mean by same page? the page where the form is at or the page where the button/image is linking to the form page, also how do i use the other code?

Will this work for the function:

Expand|Select|Wrap|Line Numbers
  1. function onload()
  2.  {document.getElementById("aaq").url.value = location.href;}
ask is the ID of my form.

and i added this as a hidden value to my form:
Expand|Select|Wrap|Line Numbers
  1. <input type=hidden name=url value="">
Aug 8 '08 #14

P: 17
yea can we use PHP as the server side language? and what do you mean by same page? the page where the form is at or the page where the button/image is linking to the form page, also how do i use the other code?

Will this work for the function:

Expand|Select|Wrap|Line Numbers
  1. function onload()
  2.  {document.getElementById("aaq").url.value = location.href;}
ask is the ID of my form.

and i added this as a hidden value to my form:
Expand|Select|Wrap|Line Numbers
  1. <input type=hidden name=url value="">

nvm disregard this, i found another way. thanks
Aug 9 '08 #15

acoder
Expert Mod 15k+
P: 16,027
That's good to hear. What did you use in the end?
Aug 9 '08 #16

P: 17
That's good to hear. What did you use in the end?
Instead of linking it to a popup or another page, we kept it on the same page. We have it so that when you click on our link, it just opens up a panel below it showing the form, that way we keep the people on the actual page and i can just use the hidden input for the item name/number. I used dreamweaver collapsible panel.
Aug 10 '08 #17

P: 17
Also, I have a couple of folders setup with an index.html file setup in them, so that if someone wants to go to that file instead of typing i.e.
www.somesite.com/carsandtrucks.html (an actual page), they can type www.somesite.com/carsandtrucks (a folder) and the index.html in that folder automatically comes up of course, ive done this for like the main categories, like
www.somesite.com/carsandtrucks and then a sub category www.somesite.com/carsandtrucks/cars. Should i also do it for the actual product? so instead of
www.somesite.com/carsandtrucks/cars/item123.html (page), they can do
www.somesite.com/carsandtrucks/cars/item123 (folder). Only problem with this i see is a lot of folders and a lot of index.html files. What do you think?

How i had it before was www.somesite.com/carsandtrucks.html and www.somesite.com/carsandtrucks/cars.html , then www.somesite.com/carsandtrucks/cars/item123.html, meaning
www.somesite.com/carsandtrucks and www.somesite.com/carsandtrucks/cars directory gave errors when you typed it in since the folder themselves didnt have an index.html.

Also is it possible just to be able to make actual pages not have the .html? like i see this exact page you dont need to type anything at the end like .html or .php, it just comes out, how does that work, must be some server side language?
Aug 10 '08 #18

acoder
Expert Mod 15k+
P: 16,027
If you're using Apache, you can use mod_rewrite. If you have problems implementing it or have any questions, ask in the Apache forum.
Aug 10 '08 #19

Post your reply

Sign in to post your reply or Sign up for a free account.