CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2007
    Posts
    5

    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>
    Last edited by madchops1; May 18th, 2007 at 08:46 AM.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    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 &#91;code&#93; tags. They are used in the following manner...

    &#91;code&#93;
    Your code goes here.
    &#91;/code&#93;
    Last edited by PeejAvery; May 18th, 2007 at 08:34 AM.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    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?
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    May 2007
    Posts
    5

    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. ?????

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    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()">
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  6. #6
    Join Date
    May 2007
    Posts
    5

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured