illuz1on Posted February 12, 2008 Share Posted February 12, 2008 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] Quote Link to comment https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/ Share on other sites More sharing options...
haku Posted February 12, 2008 Share Posted February 12, 2008 And? Quote Link to comment https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/#findComment-464959 Share on other sites More sharing options...
illuz1on Posted February 12, 2008 Author Share Posted February 12, 2008 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); } Quote Link to comment https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/#findComment-465055 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 Well if you read your first post, you never asked a question. Im not sure what you mean by "And"... Quote Link to comment https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/#findComment-465062 Share on other sites More sharing options...
haku Posted February 12, 2008 Share Posted February 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/90709-using-javascript-variables-in-php-mail/#findComment-465066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.