Jump to content

using javascript variables in php mail?


illuz1on

Recommended Posts

Hey,

 

I have a script that gets a whole bunch of values over a couple of pages, and this is how it output's at the moment.

 

function showValues(form){
var values = '';
var len = form.length - 1; //Leave off Submit Button
for(i=0; i<len; i++){
	if(form[i].id.indexOf("C")!=-1||form[i].id.indexOf("B")!=-1)//Skip Continue and Back Buttons
		continue;
	values += form[i].id;
	values += ': ';
	values += form[i].value;
	values += '\n';
}
alert(values);
}
[code]

Im trying to get these values to something I could use in a PHP Mail function, so I can let the owner of the site see what the user selected, in the email the mailer sends him.

Alternatively, if I could insert them into a database that would also be fine..

Any advice on how I would go about this?

Thanks
Chris

[/code]

Link to comment
Share on other sites

Im not sure what you mean by "And"...

 

Well at the moment it brings up a box with all the id's and the values. I want to be able to use those values in a PHP mail function... but cant see how to?

 

 

function showValues(form){
var values = '';
var len = form.length - 1; //Leave off Submit Button
for(i=0; i<len; i++){
	if(form[i].id.indexOf("C")!=-1||form[i].id.indexOf("B")!=-1)//Skip Continue and Back Buttons
		continue;
	values += form[i].id;
	values += ': ';
	values += form[i].value;
	values += '\n';
}
alert(values);
}

 

 

Link to comment
Share on other sites

You don't need javascript for this at all. In fact, unless you are trying an AJAX solution, you can't do what you are trying to with javascript.

 

What you need to do is submit the form to another page (set the "action" attribute in the <form> tag), then access each of the variables that the person has set using $_POST['variable_name'] in order to set the parts you need for your mail function.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.