Form Submit Works in IE not in Firefox?
This is a contact form it works perfectly in IE, but not at all in fire fox, it goes into the process_contact function but doesn't come out. Thanks in advance, for the support.
Code:
<head>
/////////////////////////////////////////////////////////////////////////////////////////////
<script language="JavaScript" type="text/javascript">
var receiveReq = getXmlHttpRequestObject();
function getXmlHttpRequestObject()
{
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
return ajaxRequest;
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
return ajaxRequest;
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
return ajaxRequest;
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
}
function process_contact() {
receiveReq.open("GET", "contact.php", true);
receiveReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
var email = document.getElementById('contact_email').value;
var content = document.getElementById('contact_content').value;
var filled = document.getElementById('contact_filled').value;
receiveReq.onreadystatechange = handle_process_contact;
receiveReq.send('contact_email=' + email + '&contact_content=' + content + '&contact_filled=' + filled);
}
function handle_process_contact() {
if (receiveReq.readyState == 4) {
document.getElementById('span_result').innerHTML = receiveReq.responseText;
}
}
////////////////////////////////////////////////////
</script>
</head>
<body>
<?
//////////////////////////////////////////////////////
//Begin contact.php
$contact_filled = $_REQUEST['contact_filled'];
if($contact_filled == "filled"){
$contact_email = $_REQUEST['contact_email'];
$contact_content = $_REQUEST['contact_content'];
if($contact_email == "" or $contact_content == ""){
$report = "Please fill in all *required fields.";
} else {
$insert = "INSERT INTO email SET
email_id = '',
email = '$contact_email'
";
$resres = mysql_query($insert) or die ("err 12154587.023265");
$to = "madchops11@yahoo.com";
$subj = "(KarlSteltenpohl.com Contact Message)";
$head = "From: $contact_email <$contact_email>";
$mess = "
$contact_content
";
@mail($to, $subj, $mess, $head, $add) or die("Help Email Failed");
$report = "Contact Message Sent. Thank You.";
}
}
?>
<form action="#" method="post">
<p>
<label>*Email</label>
<input name="contact_email" type="text" value="<? echo"$contact_email";?>" />
</p>
<p>
<label>*Message</label><br />
<textarea name="contact_content" id="contact_content" cols="30" rows="10"><? echo"$contact_content";?></textarea>
</p>
<input type="hidden" name="contact_filled" id="contact_filled" value="filled" />
<p align="center"><a href="javascript: process_contact();"><img src="images/submit.gif" border="0" onclick="javascript: process_contact();" /></a></p>
</form>
</body>
Re: Form Submit Works in IE not in Firefox?
Have you even checked the Error Console located under the Tools menu? That should be your first stop since it is a debugger.
EDIT: Please remember to use [code] tags. They are used in the following manner...
[code]
Your code goes here.
[/code]
Re: Form Submit Works in IE not in Firefox?
1) PLEASE edit your post to include code tags. It is covered in multiple FAQs and directly in my signature below.
2) What specific line does it get stuck at? What is the state of the variables?
Re: Form Submit Works in IE not in Firefox?
im not sure what line it gets stuck at but the state of the variables in ie is all good. In firefox if you click the submit button it doesn't put the variables through, it is like it is killing the ajax request because I cant click on any other liks to ajax functions. However if I hit enter instead of using the button it takes me to my home page (so it doesn't open up the contact.php file), but my vars are all in the url. ?????
Re: Form Submit Works in IE not in Firefox?
Two things...
1. You still haven't mentioned checking the Error Console for help as I mentioned in my first post.
2. The reason the return key changes something is because it is submitting the form. What you need to do is replace your link with javascript: process_contact() for an actual submit button. Then change the <form> tag.
Code:
<form action="#" method="post" onsubmit="process_contact()">
Re: Form Submit Works in IE not in Firefox?
Thanks Ill try that, I used the error console, I didn;t get much, nothing that would cause this problem.
I will try the action in the form. If that doesn't work. I think I will use a library to get around browser problems w/ajax.