Forum Moderators: open

Message Too Old, No Replies

filling value of input field based on referral url and sending email

setting the value of a hidden input based on referral url

         

porshals

3:43 am on Jan 15, 2009 (gmt 0)

10+ Year Member



hey guys,
I'm wondering if someone can help me out as I'm new to JS.

I have a short HTML form which gets the user details such as Name, email, phone and state.

There is a requirement to include the referral URL which I discovered I could use:

<script>
function start() {
var ref = document.getElementById('httpref');
ref.value = document.referer;
}
onload = start;
</script>

<input type="hidden" id="httpref" name="httpref" value="">

I have one problem though. If the referral url is example1.com, example2.com, example3.com it needs to send an email to whoever@wherever.com

but if the referal url is waydifferent.com it needs to send an email to another address.

Can this be done in javascript by using hidden input fields and if so what code should I use?

I hope that makes sense!

Fotiman

4:55 am on Jan 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld! To answer your question, you can't really "send email" via JavaScript. JavaScript runs client side in the browser. Email would need to be sent from the server. Now, you *could* use AJAX to tell the server to send email, but you still need some server side code (PHP, ASP, JSP, etc.) to send the mail. Also, it wouldn't work for any users that had JavaScript disabled. That also means that your example above will not work for users with JavaScript disabled either. Instead, whatever server side language you're using should populate the hidden input field.

porshals

5:00 am on Jan 15, 2009 (gmt 0)

10+ Year Member



yeah i thought that was the case!