SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Populate Form Field
Hybrid View
-
Sep 24, 2002, 08:34 #1
- Join Date
- Dec 2000
- Location
- The Sea of Tranquility
- Posts
- 696
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Populate Form Field
This may well be very simple, so please forgive my lack of javascript knowledge.
I've got a site which has a different email address on each page. What I need to do is, when someone clicks on the email address, it populates a text box on a different page with the email address that was clicked.
Then, I need the form to submit an email to the email address that has been specified by clicking the link.
Help please!!!
-
Sep 24, 2002, 10:37 #2
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Put the email address in the link's query string, like this
<a href="differentpage.htm?email=xxx@yyy.zz">Send an email to xxx@yyy.zz</a>
In differentpage.htm you can get the email with...
var email = location.search.substr(location.search.indexOf('email=') + 6);
...and then put it in the text box...
document.forms[0].elements[0].value = email;
If you have more than one variable in the query string, use a more general method
Like this: Request Object for Javascript
-
Sep 25, 2002, 08:39 #3
- Join Date
- Dec 2000
- Location
- The Sea of Tranquility
- Posts
- 696
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cheers Jofa, it's working like a dream.
I have a new problem now though. I need to get the form submitting to the email address that has populated the text box.
Things are never simple
-
Sep 25, 2002, 09:12 #4
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
document.forms[0].action = 'mailto:' + email;
Or, even better:
document.forms[0].action = 'mailto:' + email + '?subject=Some descriptive title';
NB! The form's other attributes must be...
<form method="post" enctype="text/plain">
Things are often more simple than you think
-
Sep 25, 2002, 09:27 #5
- Join Date
- Dec 2000
- Location
- The Sea of Tranquility
- Posts
- 696
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yep, that worked fine.
The only problem is that I get a pop-up box saying "This form is being submitted using e-mail." Blah Blah Blah. Then is it says "A program is trying to automatically send email on your behalf." and it warns about a virus. Is there any way round this???
-
Sep 25, 2002, 10:42 #6
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Changing security settings in Outlook, but I wouldn't recommend that
Anyway, if you change your security settings, that doesn't change what all other users will see
Bookmarks