PDA

View Full Version : [Scriptaculous] Any1 know whats up..



MrCraig
23-05-2008, 01:16 PM
Ok basically i have a contact form submission system.

All the variable names are correct as i have already tested them so that cant be the problem.



function sendcontact()
{
var type = document.getElementById("contact_type").value;
var subject = document.getElementById("contact_subject").value;
var email = document.getElementById("contact_email").value;
var message = document.getElementById("contact_message").value;

var sent = function()
{
document.getElementById("contact_form").innerHTML = "We have recieved your contact submission successfully!<br /><br />Please allow 72 hours for a reply.";
}
var fail = function()
{
document.getElementById("contact_form").innerHTML = "Sorry, an error occured!<br /><br />If this keeps happening, please let us know by emailing <a href='mailto:[email protected]'>here</a> otherwise please try again later.<br /><br />We apologize for any inconvenience caused.";
}
var loaded = function()
{

}

new Ajax.Request('contactus.php',{postBody:'?send=send&type=' + type + '&subject=' + subject + '&email=' + email + '&message=' + message + '', method:'post', onLoaded:loaded, onSuccess: sent, onFailure: fail});
}


When i run that function it goes straight to the failure message.

Any ideas whats wrong.

Ive tried commenting out the sending code on the contactus page but that doesnt make a difference.

Thanks for any help! :D

kk.
23-05-2008, 01:38 PM
now i have no idea what it is but i may aswell suggest something lol

'&message=' + message + '', method:'post', onLoaded:loaded,
after the + message + you have nothing in the '' and in all the others you do.

So yeh i have no idea lmao

Dentafrice
23-05-2008, 08:41 PM
function sendcontact()
{
var type = $('contact_type').value;
var subject = $('contact_subject').value;
var email = $('contact_email').value;
var message = $('contact_message').value;

var sent = function()
{
document.getElementById("contact_form").innerHTML = "We have recieved your contact submission successfully!<br /><br />Please allow 72 hours for a reply.";
}

var fail = function()
{
document.getElementById("contact_form").innerHTML = "Sorry, an error occured!<br /><br />If this keeps happening, please let us know by emailing <a href='mailto:[email protected]'>here</a> otherwise please try again later.<br /><br />We apologize for any inconvenience caused.";
}

var loaded = function()
{

}

new Ajax.Request('contactus.php',{postBody:'?send=send&type=' + type + '&subject=' + subject + '&email=' + email + '&message=' + message , method:'post', onLoaded:loaded, onSuccess: sent, onFailure: fail});
}

MrCraig
26-05-2008, 01:25 PM
Nope, still getting an error. :(

contactus.php file contents:


<?php
if($_POST["send"]=="send")
{
function clean($str)
{
$str = strip_tags(addslashes(stripslashes(htmlspecialchar s($str))));
$str = mysql_real_escape_string($str);
return $str;
}

$type = clean($_POST["type"]);
$subject = clean($_POST["subject"]);
$email = clean($_POST["email"]);
$message = clean($_POST["message"]);
$message = nl2br($message);

$mailbody = " Message Subject: $subject \n Reply-To Address: $email \n\n Message \n $message";
$subject = "HabboSoft Contact - [$type]";

mail("[email protected]",$subject,$mailbody,"from: <$email>");
}
?>

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Welcome to the Contact Us page</title>
</head>

<body>

<p><font face="Verdana" size="1">Welcome to the <font color="#51A5E3"><b>Contact
Us</b></font> page. If you wish to order a product from us, ask us a question or
simply provide us with some feedback, then this is where you can send it from.
All replies will be read by either <font color="#51A5E3"><b>Cj555</b></font> or </font><img border="0" src="page/cj555_desk.png" width="146" height="112" align="right"><font face="Verdana" size="1">
<font color="#51A5E3"><b>C</b></font></font><font face="Verdana" size="1"><font color="#51A5E3"><b>-Storm</b></font> and will be replied to if it is
required to. We aim to reply to all emails within <b>72</b> hours. However,
please note that this may not always be the case and we advise that if you do
not receive a reply within 14 days, you should resend your order/query/feedback
to us.</font></p>

<p>
<font face="verdana" size="1">
<div id="contact_form">
Type of Querie:<br />
<select name="type" id="contact_type">
<option selected="selected">Choose One..</option>
<option>Sales</option>
<option>Support</option>
<option>Suggestion</option>
<option>Other</option>
</select><br /><br />
Message Subject:<br />
<input name="subject" id="contact_subject" type="text" size="30" /><br /><br />
Your Email Adress:<br />
<input name="email" id="contact_email" type="text" size="40" /><br /><br />
Your Message:<br />
<textarea name="message" cols="40" rows="5" id="contact_message"></textarea><br /><br />
<input type="submit" value="Contact Us!" onclick="sendcontact()" /><input type="reset" value="Clear Form" onclick="cls()" />
</div>
</font>
</p>

</body>

</html>

Dentafrice
26-05-2008, 01:27 PM
It would help if you could tell us what error you are getting..

MrCraig
26-05-2008, 01:32 PM
Still the same problem as was happening first..

The function is going straight to the onFailure condition.

Dentafrice
26-05-2008, 01:34 PM
Well since you're not using onLoaded, why do you have that defined in your options?

MrCraig
26-05-2008, 01:46 PM
Im using jakes code as a template. At first i tried it without the onLoaded function present but that went to the onFailure message too. So i put it back in and havent removed it again yet.

Invent
26-05-2008, 03:04 PM
function sendcontact()
{

var type = document.getElementById("contact_type").value;
var subject = document.getElementById("contact_subject").value;
var email = document.getElementById("contact_email").value;
var message = document.getElementById("contact_message").value;

var sent = function()
{
document.getElementById("contact_form").innerHTML = "We have recieved your contact submission successfully!<br /><br />Please allow 72 hours for a reply.";
}

var fail = function()
{
document.getElementById("contact_form").innerHTML = "Sorry, an error occured!<br /><br />If this keeps happening, please let us know by emailing <a href='mailto:[email protected]'>here</a> otherwise please try again later.<br /><br />We apologize for any inconvenience caused.";
}

new Ajax.Request('contactus.php',
{

parameters:'send=send&type=' + type + '&subject=' + subject + '&email=' + email + '&message=' + message + '',
method:'post',
onSuccess: sent,
onFailure: fail
}
);

}


If it doesn't work, upload the two files and give me the URL.

MrCraig
27-05-2008, 06:41 PM
Nope still not working =[

Want to hide these adverts? Register an account for free!