Hey thanks,
I finally managed to get the desired output (by investing a lot of time and logic). so i thought i'd share it.
Create a boilerplate question
<script language="javascript">
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sendemail() {
var emailaddress = document.limesurvey.emailaddress.value;
document.limesurvey.send.disabled=true;
document.limesurvey.send.value='Sending....';
http.open('get', 'http://yourdomain.com/mailtest.php?emailaddress='+emailaddress+'&action=send');
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
update = response.split('|');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
</script>
<div id="contactarea"><!--<form id="contactform" name="contactform">--> <label>{INSERTANS:66911X1X4}</label><br />
<input type="hidden" value="{INSERTANS:66911X1X4}" name="emailaddress" id="emailaddress" /> <input type="button" id="submitbutton" onClick="sendemail();" name="send" value="Send Email" /> <!--</form>--></div>
in the code inserted the insertans to get the email id from a previous text question
then created a php file
[code type=php
$to = $_GET["emailaddress"]; //This is the email address you want to send the email to
if(!isset($_GET))
{
die("You are not authorised to access this page directly!"); //Just to stop people from visiting mailtest.php normally
}
$subject = "Test mail";
$message = '<html>
<head>
<title>Test Mail</title>
</head>
<body>
<p>This is a Test Mail!</p>
<table>
<p>Dear Customer,<br> <br>We thank you for being a part of.....</p>
</body>
</html>';
$from = "
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:" . $from;
mail($to,$subject,$message,$headers); //a very simple send
echo 'contactarea|Thank you '.$to.', your email has been sent.'; //now lets update the "contactarea" div on the contact.html page. The contactarea| tell's the javascript which div to update.
?>][/code]<?php
named the file mailtest.php and uploaded it somewhere on our site
thats it.. works like a charm for me. hope it will be of use to someone else.
Regards,
Samba